W3C home > Mailing lists > Public > www-style@w3.org > August 2010

Re: [cssom-view] scrollWidth vs clientWidth

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 18 Aug 2010 20:14:38 -0700
Message-ID: <AANLkTikeDqyDJcRKQUmbLA+D3j+DuznXpASOKQEQHsNY@mail.gmail.com>
To: David Flanagan <david@davidflanagan.com>
Cc: Anne van Kesteren <annevk@opera.com>, www-style@w3.org
On Wed, Aug 18, 2010 at 11:32 AM, David Flanagan
<david@davidflanagan.com> wrote:
> Tab Atkins Jr. wrote:
>>
>> Changes made: http://www.xanthir.com/diagrams/scrollwidth-clientwidth.html
>>
>
> The diagram makes it clear what happens when an element's content is wider
> than the content area. What about the opposite, though: what if the content
> is smaller than the content area.  Is scrollWidth the same as clientWidth in
> that case, or is it smaller?

Same.  If the content doesn't overflow the content area, then the
content area is whatever is given by the appropriate CSS rules.

data:text/html,<!doctype html><div style="width: 400px; padding: 50px;
border: 2px; overflow:scroll;" id=foo>foo foo</div><script>var el =
document.getElementById('foo'); alert(el.clientWidth + "\n" +
el.scrollWidth);</script>

~TJ
Received on Thursday, 19 August 2010 03:15:29 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:30 GMT