Sub topic 11
Adapt the design across breakpoints
This chapter assumes you have a high-fidelity mockup with a grid, a spacing scale, and a type scale. It also assumes you know basic CSS terms such as media query and grid. Here you adapt that mockup so it works at phone, tablet, and desktop widths.
What a breakpoint is
A breakpoint is a viewport width at which the layout changes. You don't pick breakpoints from device lists. You pick them where the content starts to look wrong: lines get too long, columns get too narrow, or gaps look empty.
Start from the smallest screen and add rules as the space grows. This is called mobile-first. It forces you to rank content, which you already did in the information hierarchy.
Choose a small set of frames
Most homepage designs need three frames in the design tool. Name them by purpose, not by device.
| Frame | Width to design at | Columns | Typical change |
|---|---|---|---|
| Small | 360 px | 1 | Stacked sections, menu behind a button |
| Medium | 768 px | 2 to 3 | Features in a row, larger spacing |
| Large | 1280 px | 12-column grid, centered | Full navigation, wider hero |
Treat these as examples. Check the frames in between, because layouts often break at 600 px or 1000 px rather than at the frame widths.
What changes and what stays
Keep the order of content the same unless the hierarchy says otherwise. Change the arrangement, not the story.
- Navigation: collapse links into a menu button on small screens and show them in the header on large ones.
- Hero: keep one primary call to action visible without scrolling at every width.
- Features: stack in one column, then place three side by side.
- Spacing: use larger steps of the spacing scale as width grows.
- Type: scale headings up modestly. Body text stays at 1rem.
Turn the frames into CSS
The mockup's decisions map directly to a mobile-first stylesheet. The base rules describe the small layout. Media queries add changes as the width grows.
:root {
--space-2: 1rem;
--space-3: 1.5rem;
--space-4: 2.5rem;
--font-size-h1: 2rem;
}
.features {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-3);
padding: var(--space-4) var(--space-2);
}
@media (min-width: 48rem) {
:root {
--font-size-h1: 2.5rem;
}
.features {
grid-template-columns: repeat(3, 1fr);
}
}
@media (min-width: 80rem) {
.features {
max-width: 72rem;
margin-inline: auto;
}
}The breakpoint values use rem, so they respect a user's browser font size. The heading size changes by redefining a custom property, so every rule that uses it updates at once.
Common errors
- Designing only the large frame. The mobile version then becomes a rushed afterthought. Design the small frame first.
- Hiding content on small screens. If something matters on desktop, visitors on phones need it too. Move it lower instead of removing it.
- Tiny tap targets. Buttons and links need roughly 44 by 44 px of touch area.
- Lines that run too long. Cap text width near 65 characters, for example with
max-width: 65ch. - Fixed widths. Use fluid widths and
max-width, not a set pixel width, so in-between sizes don't break.
Exercise
A features section shows three columns at 768 px, but the cards look cramped at 800 px. Should you add a device-specific breakpoint for a particular tablet? What would you do instead?
Show answer
No. Breakpoints should follow the content, not specific devices. Move the three-column rule to a wider breakpoint, such as 60rem, or let the grid use repeat(auto-fit, minmax(14rem, 1fr)) so columns drop out when they get too narrow. Then retest at widths around the change.