-1
我正試圖將圖像(之後)放在父級圖像之後。我用盒子作爲我想要實現的例子 - 藍框應該在綠框後面,但不管我用什麼z-index似乎都不起作用。位於父級後面的僞元素
.box-wrapper {
position: absolute;
overflow: hidden;
height: 100%;
width: 100%;
top: 0;
z-index: 1;
}
.box {
background-color: green;
position: relative;
display: block;
height: 52px;
width: 72px;
z-index: 53;
top: 2%;
z-index: 2;
}
.box:after {
content: '';
//position: relative;
background-color: blue;
display: block;
height: 50px;
width: 70px;
z-index: -3;
}
<div class="box-wrapper">
<div class="box"></div>
</div>
你爲什麼不僞元素添加到父'.box的-wrapper'代替,如下:'.box的-包裝:before',然後是位置吧'absolute' ? – UncaughtTypeError
@UncaughtTypeError,因爲我在.box-wrapper中有其他對象... – iyuyguyg
好吧,爲什麼你不在代碼片段中包含這些元素? – UncaughtTypeError