首页htmlelement_relationHTML Element Style - 如何在CSS生成的内容上创建负z-index

HTML Element Style - 如何在CSS生成的内容上创建负z-index

我们想知道如何在CSS生成的内容上创建负z-index。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
html {
  background-color: #282828
}

div {
  width: 320px;
  height: 240px;
  margin: -120px 0 0 -160px;
  position: absolute;
  top: 50%;
  left: 50%;
  background: #18f;
  background: rgba(17, 136, 255, .9);
}

div:before, div:after {
  display: block;
  width: 300px;
  height: 80px;
  position: absolute;
  top: 50%;
  margin-top: -40px;
  font: bold 32px/80px Arial;
  text-align: center;
}

div:before {
  left: -160px;
  z-index: -1;
  background: white;
  content: "Negative z-index";
}

div:after {
  right: -160px;
  color: white;
  background: #555;
  content: "Positive z-index";
}
</style>
</head>
<body>
  <div></div>
</body>
</html>