JSFiddle - React, Tailwind, and code Playground
HTML
<div class="header">
<div class="top"></div>
<div class="bottom">
<div class="inside"></div>
</div>
</div>
CSS
body {
margin: 0;
padding: 0;
}
.header {
position: relative;
z-index: 1;
}
.top {
background: aqua;
height: 40px;
opacity: 0.5;
position: fixed; /* important – do not change! */
width: 100%;
z-index: 5; /* important – do not change! */
}
.bottom {
background: green;
height: 40px;
overflow: hidden; /* important – do not change! */
position: fixed; /* important – do not change! */
top: 40px;
width: 100%;
z-index: 3; /* important – do not change! */
}
.inside {
background: red;
height: 40px;
position: fixed; /* important – do not change! */
top: 20px;
width: 100px;
z-index: 10; /* doesn't work! */
}