Designing full-screen mobile layouts, modal overlays, and sticky bottom sheets historically suffered from mobile viewport inconsistencies when using traditional 100vh units. On mobile devices running Google Chrome or Chromium browsers, the presence of dynamic user interface controls (such as the top URL address bar and bottom virtual navigation chrome) causes the visible screen height to expand and retract as the user scrolls. Traditional 100vh calculations evaluate against the largest possible viewport height, causing fixed bottom elements to be obscured behind the browser’s address bar. The CSS Values and Units Module Level 4 introduces modern small (svh), large (lvh), and dynamic (dvh) viewport units to resolve these layout shifts.
Understanding the Modern CSS Viewport Unit Hierarchy
Chromium evaluates viewport dimensions based on three distinct states of mobile browser interface chrome:
- Small Viewport Units (
svh/svw): Evaluates the viewport dimension assuming dynamic browser toolbars are fully expanded and visible. Applyingheight: 100svhguarantees that content fits entirely within the visible viewport without any clipping behind address bars. - Large Viewport Units (
lvh/lvw): Evaluates the viewport assuming dynamic browser toolbars are completely retracted or hidden. Best suited for background artwork or long articles where content flows naturally once the user begins scrolling. - Dynamic Viewport Units (
dvh/dvw): Adjusts dynamically in real time as the browser address bar expands or collapses during touch scrolling. Essential for responsive hero sections and interactive full-viewport maps. - Logical Variants (
dvi/dvb): Dynamic viewport inline and block units adapting seamlessly to horizontal and vertical writing modes.
Implementing Robust Mobile Layouts with CSS Fallbacks
Here is an enterprise implementation configuring full-height hero banners and sticky bottom sheets with progressive enhancement fallbacks:
/* 1. Full-Height App Container with Fallback */
.app-container {
/* Legacy fallback for older browsers */
min-height: 100vh;
/* Modern dynamic viewport adjustment */
min-height: 100dvh;
display: flex;
flex-direction: column;
}
/* 2. Guaranteed-Visible Modal Overlay */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
/* Uses svh to ensure bottom buttons are never obscured by URL bar */
height: 100svh;
background: rgba(15, 23, 42, 0.75);
display: flex;
align-items: center;
justify-content: center;
}
/* 3. Sticky Mobile Bottom Navigation Sheet */
.bottom-sheet {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
/* Max height constrained to small viewport minus header */
max-height: calc(100svh - 60px);
overflow-y: auto;
padding-bottom: env(safe-area-inset-bottom);
}
Testing Dynamic Viewports in Chrome DevTools Device Mode
Google Chrome provides specialized emulation controls to simulate dynamic toolbar expansion and collapse without needing physical mobile hardware:
- Open Google Chrome, navigate to your web application, and press Ctrl+Shift+M (or Cmd+Option+M on macOS) to toggle the Device Mode toolbar.
- Select a mobile device profile (such as Pixel 7 or iPhone 14) from the top dropdown.
- In the device toolbar, click the three vertical dots (More options) and select Show device frame.
- To test dynamic toolbar behavior, locate the Mobile Address Bar toggle in the simulation controls:
- Toggle between Expanded and Collapsed states.
- Observe how elements styled with
100svhmaintain visibility without reflow glitches. - Observe how elements styled with
100dvhsmoothly expand to occupy newly revealed pixels.
- Inspect the Rendering tab to confirm that no layout thrashing or cumulative layout shifts (CLS) occur during toolbar animations.
Best Practices for Viewport Units
- Avoid 100dvh for Heavy Layout Containers: Because
dvhrecalculates continuously as the user scrolls, applying it to complex flexbox or grid layouts can induce minor scroll jank on lower-powered mobile GPUs. Prefer100svhfor fixed heights and reservedvhfor lightweight visual elements. - Always Account for Safe Areas: Pair viewport units with CSS environment variables (
env(safe-area-inset-bottom)) to ensure content clears hardware home indicator bars on modern smartphones. - Declare Explicit Fallbacks: Declare standard
vhdeclarations directly beforedvhorsvhrules to guarantee graceful degradation on legacy Chromium engines.