Sub topic 11
Adapt the design across breakpoints
A homepage design is not finished until you have decided how it behaves at every width. This chapter turns the single-width mockup into a set of layouts for mobile, tablet, and desktop. You will choose breakpoints, decide what changes at each one, and write the CSS that matches your design frames.
This chapter assumes you have a high-fidelity mockup with a column grid, a spacing scale, a type scale, and design tokens. It also assumes you can read basic CSS. Familiarity with a design tool's auto layout or constraints is helpful.
The working model: mobile first, content decides
A breakpoint is a viewport width at which the layout changes. A media query is the CSS rule that applies styles only when a condition, such as a minimum width, is true.
Two ideas keep this work manageable.
- Mobile first. Design the narrowest layout first. It forces you to keep only what matters, and it is the order the CSS follows: base styles apply everywhere, and each
min-widthquery adds changes for wider screens. - Content decides the breakpoint. Do not pick breakpoints from a list of phone and tablet models. Widen a frame until the design starts to look wrong, such as lines of text that are too long or cards that look stretched. Put the breakpoint there.
The wireframe you already made is your guide. Its ranking of content tells you what survives on a small screen and what can wait.
Choose a small set of breakpoints
Most homepages need two or three breakpoints. More breakpoints mean more frames to design, review, and maintain.
| Frame | Typical design width | Breakpoint in CSS | Layout idea |
|---|---|---|---|
| Mobile | 375 px | none (base styles) | One column, stacked sections |
| Tablet | 768 px | `min-width: 48rem` | Two columns where content allows |
| Desktop | 1280 px | `min-width: 64rem` | Full grid, wider margins, side-by-side hero |
Use rem units in media queries. They scale with the user's browser font size, so a person who enlarges their default text gets the wider layout sooner, which usually suits larger text better. At the default size, 48rem is 768 px and 64rem is 1024 px.
The design width of a frame is not the same as the breakpoint. You design a tablet frame at 768 px, but the layout should hold from the breakpoint up to the next one. Check the in-between widths, such as 600 px and 900 px, as well.
Decide what changes in each section
Go through the homepage section by section and record the change at each breakpoint. A table like this works well as a note beside your frames.
| Section | Mobile | Tablet | Desktop |
|---|---|---|---|
| Header and navigation | Logo plus a menu button that opens a panel | Logo plus a short inline nav | Full inline nav and a button |
| Hero | Headline, one sentence, full-width button | Same, with more padding | Text left, image right |
| Features | One column | Two columns | Three columns |
| Proof | Stacked quotes | Two quotes per row | Three quotes per row |
| Footer | Stacked link groups | Two columns | Four columns |
Three rules help you fill in the table.
- Reorder, don't remove. If a section matters on desktop, it matters on mobile. Move it lower if you must, but do not delete it. Hidden content creates two different products.
- Keep the primary call to action visible. The one action you chose at the start of the project should appear in the first screen at every width.
- Convert hover to tap. A dropdown that opens on hover has no mobile equivalent. Plan for a tap, a visible state, and a way to close it.
Build the frames in your design tool
Create one frame per breakpoint and name them consistently, for example Home / Mobile 375, Home / Tablet 768, and Home / Desktop 1280. Use the same column grid definition you chose earlier but vary the column count: commonly 4 columns on mobile, 8 on tablet, and 12 on desktop. Keep the gutter and margin values on your spacing scale.
Use auto layout and constraints so a section can stretch. A button that is fixed at 320 px wide will break in a 320 px frame once you add margins. Set it to fill the container instead.
When you move from mobile to desktop, use the same components and change only their arrangement. If you find yourself drawing a different card for each width, that is a sign that you need a component variant instead.
Translate the frames into CSS
The structure from the wireframe stays the same at every width. Only the styles change. First, the page needs the viewport meta tag in its <head>. Without it, mobile browsers render the page at a desktop width and shrink it.
<meta name="viewport" content="width=device-width, initial-scale=1">The features section from the mockup is a good example of mobile-first CSS. The base rule gives one column. Each query adds columns.
:root {
--space-2: 1rem;
--space-3: 1.5rem;
--space-4: 2.5rem;
}
.features {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-3);
padding: var(--space-4) var(--space-2);
}
@media (min-width: 48rem) {
.features {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 64rem) {
.features {
grid-template-columns: repeat(3, 1fr);
max-width: 72rem;
margin-inline: auto;
}
}Notice that the spacing values come from tokens, not from numbers copied out of the design tool. Changing a token later changes every breakpoint at once.
Scale type with clamp
Type usually needs to grow between mobile and desktop. Instead of one jump at each breakpoint, you can let it scale smoothly. The clamp(min, preferred, max) function picks the preferred value but never goes below the minimum or above the maximum.
:root {
--font-size-body: 1rem;
--font-size-h2: clamp(1.375rem, 1.1rem + 1.2vw, 1.75rem);
--font-size-h1: clamp(1.875rem, 1.3rem + 2.5vw, 2.5rem);
}
h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }The rem part of the preferred value keeps the text responsive to the user's font setting. A value written only in vw ignores that setting and can fail accessibility checks.
Change the hero and navigation
The hero stacks on mobile and goes side by side on desktop. The navigation is shown in full only when there is room.
.hero {
display: grid;
gap: var(--space-3);
padding: var(--space-4) var(--space-2);
}
.hero .button {
display: block;
text-align: center;
min-height: 2.75rem;
}
@media (min-width: 64rem) {
.hero {
grid-template-columns: 1fr 1fr;
align-items: center;
}
.hero .button {
display: inline-block;
}
}The min-height of 2.75rem (44 px at the default size) gives a touch target that is large enough to tap reliably.
Review the result
The diagram shows the decision loop to follow for each breakpoint.
Test at these widths at least: 320, 375, 600, 768, 900, 1024, 1280, and 1600 px. Look for the following.
- Horizontal scrolling at any width.
- Lines of body text longer than about 75 characters.
- Images that are stretched, cropped through the subject, or far too large on mobile.
- Buttons and links smaller than 44 px in their shortest dimension on touch layouts.
- Text that overflows its container when the browser font size is increased to 200%.
Common errors
- Breakpoints taken from device names. Devices change every year. Content-based breakpoints stay valid.
- Desktop-first CSS with
max-widthqueries. This leads to overriding many desktop styles on small screens and is harder to maintain. - Pixel-only text and queries. They ignore the user's font setting.
- Fixed heights on sections. Text wraps onto more lines on narrow screens, so a fixed height cuts content off. Use padding and let height follow content.
- Large hero images sent to phones. A 2400 px image on a 375 px screen wastes data and slows the page. Provide smaller versions of the image for small screens.
Exercise
A feature card row is one column on mobile and three columns from 48rem. At 50rem (800 px), the cards look cramped and the headings wrap onto three lines. Without adding a new device-based breakpoint, what are two reasonable fixes?
Show answer
First, change the three-column breakpoint to a larger value such as 64rem, and use two columns from 48rem. The breakpoint should sit where the content stops fitting, not at a standard device width. Second, reduce what each card needs at that width, for example by lowering the heading size with clamp() or reducing the card padding with a spacing token. Either way, retest the in-between widths such as 600, 800, and 1000 px afterwards.