I'm trying to see if it's possible to have elements interwoven. I have a feeling it's not even possible. The only caveat to the solution is that b
is a child element to a
, d
is a child element to c
, and a
and c
are siblings (pretty much the html cannot change to to business rules).
Html
<div style="position:relative;margin-top: 50px">
<div class="z a">
<div class="z b"></div>
</div>
<div class="z c">
<div class="z d"></div>
</div>
</div>
CSS
.z{ position: absolute }
.a{ left: 10px; right: 10px; top: 10px; height: 50px; background-color: blue;}
.b{ left: 50px; right: 50px; top: 10px; height: 50px; background-color: red;}
.c{ left: 20px; right: 20px; top: 30px; height: 50px; background-color: green;}
.d{ left: 10px; right: 10px; top: 10px; height: 50px; background-color: purple;}
.a{ z-index: 1;}
.b{ z-index: 2;}
.c{ z-index: 1;}
.d{ z-index: 2;}
Actual Result:
Expected Result: