The video picks up with the full-height header at the top of Rosa’s home page, set to height: 100vh. On a model of her phone, 360 pixels wide, she sees 640 pixels of the page while the browser’s toolbar is shown, and 720 once she scrolls and the toolbar slides away. These are round numbers for a model: real phones differ.
In this video, you made the header fit her screen and keep its size while she scrolls, and you pinned a Book a lane bar to the bottom of the screen. Here are the main points and the final code.
Key Points
100vhis 720 pixels in the model, whatever the toolbar does. So with the toolbar shown, the header’s last 80 pixels are hidden under the toolbar. The header centers its text in all 720 pixels, so on Rosa’s screen that text sits 40 pixels below the middle. Her links are still in view, but the header doesn’t fit. Watch out:100vhis measured with the toolbar hidden, so it isn’t the height you see.- A common tip says to swap
vhfordvh. Withheight: 100dvh, the header is 640 pixels tall while the toolbar is shown, and it fits. But as the toolbar hides, the header grows to 720 and pushes the Today panel below it 80 pixels down the page. When the toolbar returns, it all moves back up. (The model holds the scroll still, so these shifts are the toolbar’s alone.) That tip is a detour:dvhfits, but the page shifts while Rosa reads it. - A phone has three viewports:
- The small viewport is the area you see with the toolbar shown, 640 pixels in the model.
1svhis 1 percent of it. - The large viewport is the area with the toolbar hidden, 720 pixels. Both
lvhandvhmeasure it. - The dynamic viewport is the current one, anywhere from 640 to 720.
dvhchanges as the toolbar moves, though browsers may update it in steps. - A full-height header like this is often called a hero. For it,
min-height: 100svhfits with the toolbar shown and then keeps its size: when the toolbar slides away, the header stays 640 pixels tall, the Today panel keeps its place in the page, and Rosa sees 80 more pixels instead. - Use
min-heightrather thanheight, so the header can still grow if its text needs more room. - Keep
dvhfor something that must fill the visible area, such as a full-screen closure notice. It has nothing below it to push, so its resizing doesn’t move anything Rosa reads. - The Book a lane bar is a fixed link, 3 rems tall. Placed at
100vhminus its height, its top is 672 pixels, under the toolbar. Set itsinset-block-endto0instead: a fixed element is placed against the area you see, so its bottom follows the visible bottom. It sits right above the toolbar and slides down with the toolbar as it hides. Pad the end of the page by3remtoo, so the bar never covers the last card. - The rule: size a full-height header with
min-heightandsvh, so it fits and keeps its size. Usedvhonly for something that must fill the visible area, with nothing below it to push. Pin a bottom bar withinset-block-end, so it follows the toolbar. - DevTools’ device mode has no toolbar that hides, so
svh,lvhanddvhall give the same length there. To see the difference, scroll the page on a real phone.