Avoid 100vh On Mobile Web | chanind.github.io
Viewport units in CSS sound great. If you want to style an element to take up the full screen height, you can just set height: 100vh and voila - you have a perfect fullscreen element, which resizes as the viewport changes! Sadly, this is not the case. 100vh is broken in a subtle but fundamental way on mobile browsers that makes it nearly useless. It’s best to avoid 100vh and instead rely on javascript to set heights for a full viewport experience.
Viewport units in CSS sound great. If you want to style an element to take up the full screen height, you can just set height: 100vh and voila - you have a perfect fullscreen element, which resizes as the viewport changes! Sadly, this is not the case. 100vh is broken in a subtle but fundamental way on mobile browsers that makes it nearly useless. It’s best to avoid 100vh and instead rely on javascript to set heights for a full viewport experience. The core issue is that mobile browsers (I’m looking at you, Chrome and Safari) have a “helpful” feature where the address bar is sometimes visible a
related reading
- <meta name="viewport"> HTML attribute value - HTML | MDNdeveloper.mozilla.org
- What will you ship?rauno.me
- Animating height: auto — nemzes.netnemzes.net
- Web Interface Guidelinesvercel.com
- How we built the v0 iOS app - Vercelvercel.com
- Transitions.dev — Essential transitions for web appstransitions.dev
- GitHub - vercel-labs/web-interface-guidelines: Guidelines for building interfaces on the Web.github.com
- Cheng Lou on X: "My dear front-end developers (and anyone who’s interested in the future of interfaces): I have crawled through depths of hell to bring you, for the foreseeable years, one of the more important foundational pieces of UI engineering (if not in implementation then certainly at https://t.co/BKnwCDIp75" / Xx.com
- Using CSS Transitions on Auto Dimensions | CSS-Trickscss-tricks.com
- 50 ways to vertically center content on a webpage, mostly wrongquaxio.com
- Goethe’s Advice for Young Writers by Johann Peter Eckermanntheparisreview.org
- Cascading Style Sheets, designing for the Web – Chapter 3: The amazing em unit and other best practicesw3.org