z-index: -1
for the :before
is not working when specifying z-index:2
for the box.
How to move the :before
below the box keeping the z-index:2
for the box.
.box{
background: lavender;
height: 200px;
width: 200px;
position: absolute;
left: 50%;
transform: translateX(-50%);
z-index: 2;
}
.box:before{
content: '';
width: 100%;
height: 100%;
border: 1px solid #000;
position: absolute;
right: -20px;
bottom: -20px;
z-index: -1;
}
<div class="box">
</div>
Fiddle - https://jsfiddle.net/gLnfde49/