Hello. I have a complicated multi-level menu. The (absolutely positioned) right hand menu items are spilling out of the (absolutely positioned) container in IE and Opera, but not in Firefox (or Chrome or Safari); I suspect that Firefox is wrong because I don't see why an absolutely positioned element should have its dimensions constrained by an absolutely positioned ancestor. However, it is the Firefox effect that I am trying to achieve.
My constraints are: I know the width of .outer
; however, I don't know the content (and therefore width) of any of the spans which should determine the width of .middle
. I don't know the content (and therefore width) of any of the .inner
divs, however, their width must not affect the width of the parent .middle
. The left hand edge of .inner
must line up with the left hand edge of it's sibling span. Ie, it's a two-level menu, whereby the 2nd level must be constrained within an ancester's border, but each item in the first level must not be affected by the width of its child menu.
What changes to I need to make to constrain the inner div to the boundaries of the outer div in IE? See a simplified version of the code below. In the original markup, .outer
was a ul
and .middle
was a li
.
<head>
<style type="text/css">
*{
margin: 0;
padding: 0;
list-style-type: none;
}
.outer{
border: solid 1px black;
width: 200px;
position: absolute;
}
.outer div
{
border: solid 1px green;
float: left;
}
.inner
{
position: absolute;
}
.inner p
{
border: solid 1px red;
}
span{
display: block;
padding: 0 10px;
}
.hide
{
display: none;
}
</style>
</head>
<body>
<div class="outer">
<div class="middle">
<span>outer</span>
<div class="hide"><p>lots and lots of inner text</p></div>
</div>
<div class="middle">
<span>outer</span>
<div class="hide"><p>lots and lots of inner text</p></div>
</div>
<div class="middle">
<span>outer</span>
<div class="inner"><p>lots and lots of inner text</p></div>
</div>
</div>
</body>