Attention, ceci est l'archivage statique d'un ancien site qui a maintenant disparu. En savoir plus.

Bienvenue sur , le recueil de réflexions et créations en tous genres de Nicolas Hoizey, passionné de Web depuis 1996, co-créateur et Directeur de l’Innovation de Clever Age, photographe amateur, créateur du jeu HTML5 / SVG « esviji », etc.

Viewport height is taller than the visible part of the document in some mobile browsers

Publié le

par Nicolas Hoizey,

tagué bug, iPad, iPhone et Safari

et pas commenté

When trying to use a 100vh CSS value to build a new interface for a game that would use the full viewport, I discovered that this full height value meant the bottom of the game interface was partialy hidden behind the browser buttons bar or below the "fold" of some mobile browsers.

An issue with Apple iOS Safari

I first discovered this on my iPhone 5 and iPad 2.

Here is what this page looks like on an iPhone 5 :

Bottom hidden in iOS Safari in portrait mode
Bottom hidden in iOS Safari in landscape mode

100vh is computed for when the browser interface is hidden, after a scroll :

Full content visible in iOS Safari in portrait mode after scroll
iOS Safari in landscape mode goes full screen after scroll

As suggested by Yoav Weiss there and there, I opened a bug in Apple Bug Reporter1 and Webkit Bugzilla.

Description

When trying to use a 100vh CSS value to build an interface for a game that would use the full viewport, I discovered that this full height value meant the bottom of the game interface was partialy hidden behind the browser buttons bar of Safari iOS on iPhone, or below the "fold" on iPad.

Steps to Reproduce

  1. Open http://lab.gasteroprod.com/vub/index-ios-issue.html on iOS Safari with an iPhone in portrait mode, or an iPad in portrait or landscape mode
  2. The bottom part of the "bottom right" box is not visible, the 100vh height container being taller than the visible part

Expected Results

I would have expected the viewport size (and the 100vh dimension) to be equal to the visible part of the page in the browser. It’s called VIEWport after all.

I understand it means the viewport changes when the browser interface hides, but I find it better, and necessary for "full viewport" interfaces. Fullscreen API is not available either, so there is no simple way to fix this behavior.

Actual Results

The bottom part of the "bottom right" box is not visible, the 100vh height container being taller than the visible part

Configuration

iPhone 5 and iPad 2

Version & Build

iOS 8.1.3 (12B466), and other versions in the iOS simulator

Additional Notes

There is a JavaScript library that tries to fix some issues with viewport units in iOS, but it has issues too: https://github.com/rodneyrehm/viewport-units-buggyfill/issues/13

But not the only one…

In fact I saw later that iOS Safari is not the only one doing this.

Firefox on Firefox OS

I discovered later the same behavior on the browser of Firefox OS:

Bottom hidden in Firefox OS’s browser

So what?

Are these behaviors browsers bugs, or the correct implementation of the standard, or is it open to interpretation?

February 23rd update

Webkit bug has been set to RESOLVED WONTFIX, with this explanation:

This is completely intentional. It took quite a bit of work on our part to achieve this effect. :)

The base problem is this: the visible area changes dynamically as you scroll. If we update the CSS viewport height accordingly, we need to update the layout during the scroll. Not only that looks like shit, but doing that at 60 FPS is practically impossible in most pages (60 FPS is the baseline framerate on iOS).

It is hard to show you the "looks like shit" part, but imagine as you scroll, the contents moves and what you want on screen is continuously shifting.

Dynamically updating the height was not working, we had a few choices: drop viewport units on iOS, match the document size like before iOS 8, use the small view size, use the large view size.

From the data we had, using the larger view size was the best compromise. Most website using viewport units were looking great most of the time.

March 4th update

The issue on Apple Bug Reporter has been closed with this comment:

This issue behaves as intended.

Meh…

The W3C CSS Working Group replied on Twitter with links to past discussions:

March 9th update

The W3C CSS Working Group suggestion doesn’t fix anything, in iOS at least. Test it live here.

Footnotes

1Id 19879505