W3C home > Mailing lists > Public > www-style@w3.org > January 2014

Re: [css3-box] How do scrollbars affect width calculation?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sun, 26 Jan 2014 22:16:23 -0500
Message-ID: <52E5CF87.8070909@mit.edu>
To: Sebastian Zartner <sebastianzartner@gmail.com>
CC: www-style list <www-style@w3.org>
On 1/26/14 3:53 PM, Sebastian Zartner wrote:
> No, I just put Thomas' code into a file. For clarity I attached the file.

Interesting.  So here's a modified version of this testcase that's worth 
considering:

<!DOCTYPE html>
<div style="width:20px;padding:20px;overflow:scroll; border: 1px solid 
purple">
   <div style="background: green; height: 20px"></div>
</div>
<div style="width:20px;padding:20px;overflow:visible; border: 1px solid 
purple">
   <div style="background: green; height: 20px"></div>
</div>
<script>
alert(getComputedStyle(document.querySelector('div')).width);
alert(getComputedStyle(document.querySelector('div').firstElementChild).width);
</script>

the actual rendering looks the same across UAs (about 5px for the inner 
div in the overflow:scroll case, for me).  The first getComputedStyle 
returns different values in different UAs, as you note.  The second one 
returns 5px reliably.

I have no idea what browsers are actually doing here.

> Will this behavior change with dropping the '-moz' prefix[1]?

No, since box-sizing is not involved in any way.

-Boris
Received on Monday, 27 January 2014 03:17:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:39 UTC