I have 3 levels of div
:
- (In green below) A top level
div
withoverflow: hidden
. This is because I want some content (not shown here) inside that box to cropped if it exceeds the size of the box. - (In red below) Inside this, I have
div
withposition: relative
. The only use for this is for the next level. - (In blue below) Finally a
div
I take out of the flow withposition: absolute
but that I want positioned relative to the reddiv
(not to the page).
I'd like to have the blue box be taken out of the flow and expand beyond the green box, but be positioned relative to the red box as in:
However, with the code below, I get:
And removing the position: relative
on the red box, now the blue box is allowed to get out of the green box, but is not positioned anymore relative to the red box:
Is there a way to:
- Keep the
overflow: hidden
on the green box. - Have the blue box expand beyond the green box and be positioned relative to red box?
The full source, with inline CSS for the sake of testing:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<br/><br/><br/>
<div id="1" style="overflow: hidden; background: #efe; padding: 5px; width: 125px">
<div id="2" style="position: relative; background: #fee; padding: 2px; width: 100px; height: 100px">
<div id="3" style="position: absolute; top: 10px; background: #eef; padding: 2px; width: 75px; height: 150px"/>
</div>
</div>
</body>
</html>