liveBook · Manning

Dynamic viewport unit

As explained in Math for Web Design

The dvh unit is a CSS viewport-height unit equal to one percent of the dynamically changing viewport height as browser interface elements appear or disappear.

The `dvh` unit equals one percent of the browser’s current visible viewport height. Unlike `vh`, it updates when mobile browser interface elements, such as address bars, appear or disappear. section 3.1.4 section 6.4.4

Use `dvh` when an element should follow the visible screen:

  • `height: 100dvh` makes a panel or background fill the visible viewport at the current moment. section 6.4.4
  • A full-page image using `100vh` can extend beneath mobile browser UI; replacing it with `100dvh` reflects the height actually visible on load. section 6.4.5 section 6.6
  • Dynamic resizing can reflow content during scrolling, so reserve `dvh` for crucial panels and screen-filling elements rather than long text pages. section 6.4.4

A screen-filling mobile panel

Use `height: 100dvh` when a panel must track the visible screen as browser UI changes. For a multipanel app, combine it with fixed viewport-based rows: `.app { display: grid; grid-template-rows: 10svh 1fr 8svh; height: 100dvh; }`. section 6.4.4 section 6.6

Listing 6.5 The 100dvh overflow fix
.fullscreen {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

Inspect the complete `.fullscreen` rule that applies `100dvh` to a centered, vertically distributed panel. section 6.4.4

How Math for Web Design covers it

How deep it goes
Explains the one-percent calculation, compares dynamic behavior with `vh`, and warns about scroll-induced reflow.
Examples
Uses fullscreen panels, mobile images, and a toolbar-content-footer grid with `100dvh` and `svh`.
What it assumes
Assumes basic CSS sizing and viewport-unit knowledge while defining the needed viewport mathematics from one percent upward.
What you can do after
Apply `dvh` to correct mobile fullscreen overflow and build layouts that adapt as browser interface chrome changes.
How it connects
Connects dynamic viewport units with viewport units, responsive design, mobile browser UI, and CSS Grid.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.