请参阅:
div元素具有z-index值为5的相对定位,而:after伪类具有z-index值为2的绝对定位。
所以,:after不应该在div的后面吗?
div{
position:relative;
z-index: 5;
background: #000;
padding: 10px;
}
div:after{
content: '';
position: absolute;
z-index: 2; /* <= not working:( */
background: #3d3;
left: 20px;
top: 20px;
width: 30px;
height: 30px;
}
<div>erferf</div>