Re: [css3-values] Interaction of vw/vh and scrollbars

On Mon, Dec 3, 2012 at 3:02 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> Right now the V&U spec doesn't mention anything special about whether
> the presence of scrollbars affects the size of the vw/vh units.
> Here's a testcase:
>
> <!DOCTYPE html>
> <div></div>
> <style>
> body { margin: 0; overflow: scroll; }
> div {
>   background: url('http://xanthir.com/pony') no-repeat right top silver;
>   width: 100vw; height: 100vh;}
> </style>
>
> (Alter the overflow value to get different results.)
>
> In the two browsers that currently support vw/vh, Chrome and IE,
> neither one pays any attention to scrollbars.  Regardless of the value
> of overflow on <body>, they set the two values to the width/height of
> the scrollbar-less viewport.
>
> This seems suboptimal when we *know* that scrollbars will appear, like
> if overflow:scroll is set on body.
>
> Should the vw/vh units respond to this, and subtract the size of the
> scrollbars from their viewport size?
>
> (In some cases we can't tell, like if <body> is overflow:auto.  In
> that case, I think it's reasonable to either always ignore or always
> assume scrollbars.  Current behavior in browsers is to always ignore,
> so I'm fine with sticking to that.)
>

This comes down to use-cases. Not clear to me what use-cases vw/vh are
meant to meet. For example, lets say you were position:absolute'ing a mask
to cover the whole window (e.g. behind a dialog), in this case you'd want
it to be on top of the scrollbars. Yours is a use-case where you'd want the
opposite. Not really sure how to resolve both.

Received on Monday, 3 December 2012 23:34:23 UTC