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

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 UTC