Can someone explain to me why browsers render a scrollbar for an "overflow-y: visible
" element if it's inside a fixed position parent? Note that this only happens if the parent has "overflow-x: hidden". If overflow-x
is not set to hidden, overflow-y: visible
causes no scrollbar to appear, which is expected behavior.
Below is a jsfiddle example in which I expect both left and right divs to render the same, but they don't. Is there any way to get the left box render like the right one without setting a height on wrapper div and removing overflow-x
hidden from the wrapper?
CSS and HTML:
.wrapper {
position: fixed;
border: solid 1px #ccc;
width: 250px;
height: auto;
top: 10px;
overflow-x: hidden;
}
.wrapper p.absolute {
position: absolute;
}
.wrapper.first {
overflow-y: visible;
left: 10px;
}
.wrapper.second {
overflow: visible;
left: 280px;
}
<div class="wrapper first">
<p>Content that is not positioned</p>
<p class="absolute">Content is absolute positioned</p>
</div>
<div class="wrapper second">
<p>Content that is not positioned</p>
<p class="absolute">Content is absolute positioned</p>
</div>