CSS不工作之前

时间:2016-06-09 10:33:06

标签: html css

我只是建立网站一切运作良好,但当我尝试申请:之前或:在一些元素的伪元素之后,所以小泡沫应该在大的背后,它不知何故不起作用,不知道这是为什么。



.bubble {
  position: relative;
  display: table-cell;
  vertical-align: middle;
  width: 135px;
  height: 135px;
  background-color: #666;
  -webkit-border-radius: 75px;
  -moz-border-radius: 75px;
  -o-border-radius: 75px;
  -ms-border-radius: 75px;
  border-radius: 75px;
  -moz-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  -webkit-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  z-index: 10;
}
.bubble.black:before {
  top: 0;
  left: 0;
  content: "";
  position: absolute;
  width: 80px;
  height: 80px;
  background-color: #000;
  -webkit-border-radius: 75px;
  -moz-border-radius: 75px;
  -o-border-radius: 75px;
  -ms-border-radius: 75px;
  border-radius: 75px;
  -moz-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  -webkit-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  z-index: 1;
}

<div class="bubble black"></div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

您可以从父级删除z-index并在伪元素

上使用z-index: -1

&#13;
&#13;
.bubble {
  position: relative;
  width: 135px;
  height: 135px;
  background-color: #666;
  border-radius: 75px;
  box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
}
.bubble.black:before {
  top: 0;
  left: 0;
  content: "";
  position: absolute;
  width: 80px;
  height: 80px;
  background-color: #000;
  border-radius: 75px;
  box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
  z-index: -1;
}
&#13;
<div class="bubble black"></div>
&#13;
&#13;
&#13;