Given the following markup and style
div {
width: 300px;
height: 50px;
border: 1px solid black;
display: inline-block;
transition: all .1s ease-in-out;
background-color: white;
padding: 0px 5px;
}
div:hover {
transform: scale(1.2);
}
label {
/*position: relative;*/
}
<div>
<label>some random text</label>
</div>
<div>
<label>some random text</label>
</div>
when hovering over the first div
some letter from the second div
are being "hidden" under the scaled element. When, however, position: relative
is set on the label
element, the text gets rendered over the scaled element:
div {
width: 300px;
height: 50px;
border: 1px solid black;
display: inline-block;
transition: all .1s ease-in-out;
background-color: white;
padding: 0px 5px;
}
div:hover {
transform: scale(1.2);
}
label {
position: relative;
}
<div>
<label>some random text</label>
</div>
<div>
<label>some random text</label>
</div>
I'm trying to understand the reasoning behind this. Since this seams consistent across browsers, I'm thinking that it is defined in the specs. If so, what's the rationale? And how do I "turn it off", if can't touch the relative positioning?
label
s have a position other than static which implicitly changes the rendering to be "on top" of other elements including the containingdiv
s – Grillo