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

Re: [cssom-view] padding edge / border edge for offsetTop/offsetLeft?

From: Alan Gresley <alan@css-class.com>
Date: Sat, 26 Apr 2008 10:35:40 +1000
Message-ID: <481278DC.5030301@css-class.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>
CC: Sylvain Galineau <sylvaing@microsoft.com>, Mike Wilson <mikewse@hotmail.com>, Www-style <www-style@w3.org>

Garrett Smith wrote:

> Some confusion must have lead to Anne's assumption that hasLayout
> determines this behavior. In fact, that claim is provably false.
> 
> <!doctype html>
> <style>
>  body { margin:0 }
>  div { border:10px solid  }
>  div#x { border:20px solid orange; zoom:1 }
> </style>
> <div><div id=x></div></div>
> 
> javascript:alert(x.offsetTop + ", " + x.currentStyle.hasLayout)
> 
> IE7 => 10, true
> 
> Shows that the offsetTop includes the parentNode's border-width and
> also has a layout.


What Anne has said is correct. You have given hasLayout to wrong 
element. HasLayout is on the child div#x instead the parent. Reverse 
that and you may see the difference.


<!doctype html>
<style>
body { margin:0 }
div { border:10px solid; zoom:1 }
div#x { border:20px solid orange; }
</style>
<div><div id=x></div></div>


Alan
Received on Saturday, 26 April 2008 00:36:35 GMT

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