W3C home > Mailing lists > Public > www-style@w3.org > April 2008

Re: [cssom-view] Why is body's offsetParent null ?

From: Anne van Kesteren <annevk@opera.com>
Date: Wed, 23 Apr 2008 10:45:11 +0200
To: "Daniel Glazman" <daniel.glazman@disruptive-innovations.com>, "www-style@w3.org" <www-style@w3.org>
Message-ID: <op.t912llzu64w2qv@annevk-t60.oslo.opera.com>

On Wed, 23 Apr 2008 10:32:50 +0200, Daniel Glazman  
<daniel.glazman@disruptive-innovations.com> wrote:
> Anne van Kesteren wrote:
>
>> Making the HTML body element "special" helps with that. It doesn't seem  
>> very bad design either considering that the HTML body element is  
>> special in CSS and it's special with respect to event handling too.
>
> It's special wrt the 'overflow' and 'background-*' properties only as
> per CSS 2.1. So if the body element has an offset from the root element
> of the document, how are we supposed to get it ?

document.body.getBoundingClientRect().top -  
document.documentElement.getBoundingClientRect().top

or

document.body.offsetTop - document.documentElement.offsetTop


-- 
Anne van Kesteren
<http://annevankesteren.nl/>
<http://www.opera.com/>
Received on Wednesday, 23 April 2008 08:45:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:05 GMT