There are two divs side by side with same zIndex. I want to display a child div of first div over the second div kinda like an overlay. But no matter what zIndex i give to the child div, it remains below the second div.
.parent {
border: 5px dotted red;
height: 500px;
width: 500px;
display: flex;
justify-content: center;
align-items: start;
padding: 50px;
background-color: black;
}
.child {
border: 5px solid blue;
height: 100px;
width: 100px;
margin: 0 0 50px 50px;
background-color: midnightblue;
position: relative;
z-index: 10;
}
.child-hover {
position: absolute;
border: 3px solid green;
border-radius: 40px;
height: 60px;
width: 80px;
top: 0;
left: 90%;
background-color: green;
z-index: 9999 !important;
}
<div class="parent">
<div class="child">
<div class="child-hover"></div>
</div>
<div class="child"></div>
</div>
In this fiddle you'll see two blue squares and a green ellipse. Part of green ellipse is hidden beneath the second blue square. I understand that's because the second div came after the first div in the html. I don't want that to happen.
Edit: I do not wish to remove the zIndex from .child
.