Hacker News new | ask | show | jobs
by Daiz 1491 days ago
I've yet to meet a single developer who likes what Apple did with 100vh. And it's why all my projects to date that want to use viewport height in CSS have ended up adding a JS snippet that sets a --vh CSS variable to window.innerHeight on resize, because I have no interest in dealing with Apple's special boy CSS behavior. And really, even Apple itself admits that their 100vh solution is troublesome - they wouldn't have introduced all these new units otherwise! Even if the saner solution would have been to just change their idiosyncratic 100vh behavior to what developers actually expect from it.
2 comments

And what do "developers" expect from it? Because as a user I certainly remember that it used to be very common for website layout to jump around in an aggravating fashion when hiding the address bar.

These new units do not indicate that Apple's 100vh behavior is "troublesome", they indicate that mobile needs better viewport units than desktop does. Which is why there are three separate new viewport units, to correspond to the three different desired measurements. Even if Apple never changed 100vh behavior, these new set of units are a significant improvement.

100vh is a good default for unaware websites, because otherwise you get unexpected layout jump. The other units are good tools for aware developers who intentionally want to match largest, smallest, or dynamic height. Seems like best of both worlds.