I'm trying to position an element above an element having z-index greater than it's parent, as the title says.
For example, I have the following HTML:
HTML:
<div class="line">
<div class="info"></div>
</div>
<div class="box"></div>
and CSS:
body {
margin: 50px;
}
.box {
background: grey;
width: 500px;
height: 40px;
z-index: 10;
position: relative;
}
.line {
background: blue;
width: 500px;
height: 5px;
z-index: 9;
position: relative;
top: 0;
overflow: visible;
}
.line .info {
width: 50px;
height: 25px;
background: red;
}
As you can see in this jsfiddle the red line (.info
) is actually supposed to be in the shape of a larger rectangle, but the reason you don't see it is because it's hidden behind the grey .box
.
How would I change the z-index
's around so that the red box shows above the grey box, and the blue .line
stays behind the grey box?