> when in figure 11-7a i apply a percentage value at the top
> property of p#relative the p#relative doesn#039;t offset
> from the top at all in Firefox but in IE6 it does.
Since I haven't had much need for the scenario you're describing, professionally speaking, I had to do some digging on the topic.
As stated in the book, the specifications state that an element with relative positioning should be rendered as part of the normal flow of a document. i.e., it should be placed where it would be were no positioning applied. Then relative positioning is applied relative to its original, static position. So the offset properties are applied relative to that position, rather than relative to the element's parent, except for percentage measurement, which is relative to the containing element.
http://www.w3.org/TR/CSS2/visuren.ht...ve-positioning
http://www.w3.org/TR/CSS2/visuren.html#propdef-top
"For relatively positioned boxes, the offsets are with respect to the outer edges of the box itself (i.e., the box is given a position in the normal flow, then offset from that position according to these properties"
"For 'top' and 'bottom', if the height of the containing block is not specified explicitly (i.e., it depends on content height), the percentage value is interpreted like 'auto'."
That second blurb explains what you're seeing, and that behavior occurs in Firefox, Safari, and Opera, they all agree. The height of the <body> element, which is the containing block in this example, is not explicitly defined. So, the top (or bottom) property with a percentage measurement is treated like "auto", or for all practical purposes, ignored. IE6 and IE7 are incorrect per the specification since they render the offset when the height is not explicitly defined. But you get the same outcome in IE6 and IE7 when you do specify an explicit height... you see the same rendering in IE as you do in Firefox, Opera, and Safari.
As to *why* the specification defines it that way, well, your guess is as good as mine. I'm sure someone, somewhere had a compelling reason for the limitation.
> the percentage value for the top,bottom,right,left properties
> is the percentage of the containing block#039;s width or height.
> in figure 11-7b if i put the p#relative into a div
> and apply top:50%(or any other percentage value) in figure 11-7a, then > the offset from top is calculated with respect to the height of the
> body not the height of the div(IE6).
If you add a CSS rule for the <div>, and within that the declaration, zoom: 1;, you get the expected result, percentage relative to the <div>. That's needed because this looks like an IE "hasLayout" bug. That topic is covered in my book, though I don't recall where. I didn't exhaustively cover the topic, but it is covered.
For more information see this link:
http://www.satzansatz.de/cssd/onhavinglayout.html
Hope this helps!
Regards,
Rich
--
Author,
Beginning CSS: Cascading Style Sheets For Web Design, 2nd Edition
CSS Instant Results
http://www.catb.org/~esr/faqs/smart-questions.html