JSFiddle - React, Tailwind, and code Playground
HTML
<div class="main">
<div class="child1">111</div>
<div class="child2">
<span>222</span>
<div class="hover">
blablabla
<i class="popup">foo</i>
</div>
<i class="popup">goo</i>
</div>
<div class="child3">333</div>
<span class="popup">boo</span>
</div>
CSS
body {
min-height: 100%;
padding: 0;
}
.main {
border: 1px solid red;
display: flex;
flex-direction: column;
padding: 10px;
height: 100%;
width: 100%;
position: absolute;
box-sizing: border-box;
z-index: 0;
}
.child1 {
background: lightblue;
height: 100px;
z-index: 1;
}
.child2 {
background: lightgreen;
flex: 1;
overflow-y: auto;
z-index: 1;
position: relative;
}
.child2 span {
height: 320px;
display: inline-block;
}
.hover {
position: relative;
background: yellow;
}
.hover .popup {
top: 100%;
}
.child2 .popup {
top: 300px;
left: 100px;
}
.popup {
position: absolute;
top: 100px;
left: 100px;
width: 200px;
height: 50px;
padding: 5px;
background: #fff;
border-radius: 5px;
z-index: 5;
}
.child3 {
background: salmon;
height: 100px;
z-index: 1;
}