Consider the following HTML:
<div style = "overflow: hidden; height: 5em" id = "selections-outer-wrapper">
<div id = "selections-inner-wrapper" style = "position: relative">
<ul style = "text-align:left; width: 12em;">
<!---- LOTS OF LI ELEMENTS GO HERE ---->
</ul>
</div>
</div>
My intention here is that anything within the outermost DIV should be hidden (clipped) if it extends beyond 5em
in height. (That is the purpose of the overflow: hidden
style attribute.) When I render this HTML using Firefox or any Webkit-based browser, the inner content is correctly clipped.
jsfiddle link: http://jsfiddle.net/Q82N9/
Screenshot with Firefox:
However, with IE-7 it doesn't work correctly. (surprise, surprise) For some reason, the inner UL
element is not clipped, despite the overflow: hidden
property.
Screenshot with IE-7:
It seems the problem is the position: relative
styling attribute in the inner-DIV. If I remove that style attribute, it works fine on IE-7. However, I need the inner-DIV to have a relative
position, because certain Javascript code that I'm working with assumes it does in order to scroll it up and down.
Question: So, is there some reason this isn't working on IE-7? Is this a well-known problem with a workaround? Or is IE-7 actually doing the right thing and for some reason relatively positioned nodes can't be hidden
using the overflow
property.