All elements should be absolute position!
What needs to be achieved is that the element "child1" (z-index: 3;) is above "child2" (z-index: 2), both should be in the parent div (z-index: 1;).
How to make this possible?
Code:
#parent {
width: 300px;
height: 300px;
background: blue;
position: absolute;
top: 30px;
left: 30px;
z-index: 1;
}
#child1 {
width: 150px;
height: 150px;
background: red;
position: absolute;
top: 80px;
left: 80px;
z-index: 3;
}
#child2 {
width: 100px;
height: 100px;
background: green;
position: absolute;
top: -30px;
left: -30px;
z-index: 2;
<div id="parent">
<div id="child1">
<div id="child2"></div>
</div>
</div>