Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewport-units vw/vh not working as expected when non-100% zoom in Safari on OS X

I'm having trouble with vw and vh units on OSX Safari.

Take this code as an example:

<body style="margin: 0;">
    <div style="background: red;
                height: 100vh;
                width: 100vw;"></div>
</body>

At 100% zoom, it works fine. However, if you zoom out, Chrome and Firefox (with this example) still render the red div across the whole page. Safari, on the other hand, seems to be rendering as if vw and vh are calculated against the viewport at zoom 100%.

Is this the expected behaviour or is this something Safari does differently to other browsers? Are there any other browsers that render vw and vh in the same way?

like image 807
gligoran Avatar asked Aug 17 '16 09:08

gligoran


2 Answers

As I know only Safari has Problems with recalculation. See this page for more known issues with this property: http://caniuse.com/#feat=viewport-units.

like image 86
Morris Janatzek Avatar answered Oct 18 '22 06:10

Morris Janatzek


This was a bug in Safari, which was reportedly closed in November 2017. It's unclear if it will land in Safari 12 or not.

Bug: https://bugs.webkit.org/show_bug.cgi?id=145614

Changeset: https://trac.webkit.org/changeset/225277/webkit

like image 30
americanyak Avatar answered Oct 18 '22 05:10

americanyak