Sent by Alex Robinson on 14 February 2003 01:01
>Element - Positioned Absolutely
> Many Elements - Floated Left
> Sub Element- Which I want to position relative to top
>corner of parent (floated) element
>
>But what happens is the sub Element positions itself relative to the top
>corner of the last non-floated parent (the top element in the example)
OK. I positioned the sub element at the bottom right but your basic point
holds.
<http://www.fu2k.org/alex/css/cssjunk/AbsoluteFloatAbsolute.mhtml>
If you set the floated elements to also have position: relative, IE5 (pc &
mac) and IE6 work. Operas 5 and 6 simply place the sub absolute div on the
left, just below the text in the float and extend the background of the div
to the bottom of the surrounding floating div. Opera 7 and Geckos do the
last non-floated parent thing. Given IE (in all its forms) abominable
record with regard to floats, I'd wager that it's the one that's in the
wrong here (standards-wise) though once again it looks like a decision
based on "well that would be better and easier, wouldn't it?"
The relevant bit of the specs as far as I can see is "...[should] be
positioned with respect to its containing block. The containing block for a
positioned box is established by the nearest positioned ancestor (or, if
none exists, the initial containing block...)"
<http://www.w3.org/TR/REC-CSS2/visuren.html#q29>
So the floated elements just don't count as positioned ancestors since
they've been removed from the document flow.
>So, is it possible to absolutely position an element inside their
>floated parent?
Unfortunately it doesn't look like it. What you're actually after is
display: inline-block but that only got introduced in CSS2.1 and support
is as you might expect somewhat patchy
<http://www.w3.org/TR/CSS21/visuren.html#propdef-display>