JSFiddle - React, Tailwind, and code Playground
by only_dimon
HTML
<div class="container fixed">
<div class="el z1"></div>
<div class="el z3"></div>
</div>
<div class="container relative">
<div class="el z2"></div>
<div class="el z4"></div>
</div>
CSS
html, body {
height: 100%;
width: 100%;
}
.container {
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0,0,0,0.3);
}
.container.fixed {
position: fixed;
}
.container.relative {
position: relative;
}
.el {
position: absolute;
}
.z1 {
width: 200px;
height: 200px;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -100px;
background: yellow;
z-index: 1;
}
.z2 {
width: 150px;
height: 150px;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
background: green;
z-index: 2;
}
.z3 {
width: 100px;
height: 100px;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -50px;
background: white;
z-index: 3;
}
.z4 {
width: 50px;
height: 50px;
top: 50%;
left: 50%;
margin-top: -25px;
margin-left: -25px;
background: black;
z-index: 4;
}