This section combines the knowledge from the previous four sections — the box model, Flexbox, Grid, and media queries — into a real, usable page skeleton: from fluid type and an adaptive card grid to a collapsing navigation on small screens, gradually building a page that transitions smoothly from phones to desktop monitors.
Fluid Type: The clamp() Three-Value Function
clamp(minimum, preferred, maximum) lets font sizes and spacing change continuously with the viewport width, replacing the practice of hard jumps at breakpoints. The preferred value is usually written in vw units so it scales linearly with the viewport, while the minimum and maximum values act as guardrails so it never gets out of hand at extreme sizes.
Why better than media queriesWith media queries, font sizes visibly "jump" at breakpoints; clamp() makes the change continuous and smooth, and a single line of code replaces what would otherwise be three or four media query rules.
Page Skeleton: Grid as the Framework
First use Grid to define a site-wide page-level skeleton — sidebar, header, main content, footer — then on mobile use a media query to "collapse" the sidebar into the main column:
Recall the auto-fit + minmax() combination from Section 4.3 — it is inherently responsive and handles most width changes without even needing extra media queries:
Preview: shrink the browser window to watch the column count change (this demo area is narrow and already shows a one/two-column state)
Card A
Card B
Card C
Collapsing Navigation: Flexbox + Media Queries
On desktop, Flexbox lays out the navigation items horizontally in a row; on mobile, it switches to a vertical collapsed menu — changing the layout requires modifying only one property, flex-direction:
.nav-list {
display: flex;
gap: 24px;
}
@media (max-width: 640px) {
.nav-list {
flex-direction: column;
gap: 0;
display: none; /* hidden by default, toggled open by the hamburger button */
}
.nav-list.open { display: flex; }
}
Putting It All Together
Combining the snippets above yields a page skeleton with basic responsive capability: fluid type handles the continuous scaling of text, Grid handles the breakpoint re-layout of the page-level skeleton, the auto-fit grid handles the adaptive column count of the cards in the content area, and Flexbox handles the direction switch of one-dimensional components such as navigation bars before and after breakpoints. Each of the four has a clear role, solving the layer of the problem it is best at — this is the core idea of modern responsive design: not "one big all-encompassing solution", but "choosing the right tool at the right level".
Pre-launch Checklist
Did you declare <meta name="viewport" content="width=device-width, initial-scale=1"> in the <head>? Without it, media queries on mobile will not work at all.
Are the breakpoints determined by the content, rather than copied from a specific device model's resolution?
Are the clickable areas on touch devices large enough (recommended at least 44×44px)?
Did you use prefers-reduced-motion to respect the user's motion preferences (see Section 3.2)?
Has contrast and images in dark mode been checked too (see Section 3.2)?
Do horizontal scrollbars appear only inside deliberately designed containers (such as code blocks or tables), rather than unexpectedly on the whole page?