brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: min-height: 100dvh in css tracks the real visible height on a phone

Css
~/tips/tip-css-dvh-viewport-height-units

.hero { min-height: 100vh; /* fallback */ min-height: 100dvh; }

Sizes an element to the visible screen height on mobile even while the browser toolbar moves.

On a phone, 100vh is taller than what you can see while the address bar is showing.

.hero { min-height: 100vh; /* fallback */ min-height: 100dvh; }

dvh is the dynamic viewport height: it follows the browser toolbars as they slide in and out. svh is the small viewport (toolbars visible) and lvh the large one (toolbars hidden). The older vh unit matches the large one, so full-screen sections get cut off at the bottom. The first line is a fallback for browsers that do not know the new units. Because dvh changes while scrolling, an element sized with it can resize during a swipe, so svh is the calmer choice for a hero.

Further reading: MDN: CSS length units

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link