Sub topic 6
Setting up mobile, tablet, and desktop frames
This chapter assumes you know the viewport meta tag, CSS pixels, and min-width media queries from the earlier chapters. It also assumes you can use a frame-based design tool such as Figma. Here you will set up three design frames and tie each one to a CSS breakpoint, so designers and developers describe the same layout with the same numbers.
What a frame is, and what it is not
A frame is a fixed-width artboard in your design tool. It shows what the page looks like at one width. A browser window can be any width, so a frame is a sample of that range.
Three frames are the usual starting set:
- Mobile: the single-column base layout.
- Tablet: the first layout with enough room for a second column.
- Desktop: the layout with the most room, usually with a maximum content width.
The frames are not device mockups. A "tablet" frame does not mean "an iPad". It means "the layout we use once the width reaches the tablet breakpoint". Keep that distinction, because a later chapter explains why breakpoints come from content and not from device lists.
Map frames to CSS ranges
Each frame stands for a range of widths. The frame shows one point in that range, and the CSS must hold for the whole range.
| Frame | Frame width | CSS range | Media query that starts it |
|---|---|---|---|
| Mobile | 360 px | 0 to 767 px | none (base styles) |
| Tablet | 768 px | 768 to 1279 px | `min-width: 48em` |
| Desktop | 1280 px | 1280 px and up | `min-width: 80em` |
The numbers match the CSS from the mobile-first chapter: 48em is 768 px and 80em is 1280 px, because media query em units use the browser's default font size of 16 px. They do not use your page's html { font-size } setting. Changing the root font size therefore does not move your breakpoints.
.layout {
display: grid;
gap: 1rem;
padding: 1rem;
}
/* Tablet frame: 768px and up */
@media (min-width: 48em) {
.layout {
grid-template-columns: 1fr 1fr;
}
}
/* Desktop frame: 1280px and up */
@media (min-width: 80em) {
.layout {
grid-template-columns: 2fr 1fr 1fr;
max-width: 80rem;
margin-inline: auto;
}
}The mobile frame has no media query of its own. Base styles are the mobile design, and each larger frame describes only what changes.
Choose the frame widths
Place each frame at the width where its layout is meant to look right.
- Mobile at 360 px. This is a common phone width in CSS pixels. Some phones are 320 px wide, and some are 390 px or more. Design at 360, then check 320 as a stress test.
- Tablet at the breakpoint itself. Start the tablet frame at 768 px. This is the narrowest width where the tablet layout applies. If you design it at 1000 px, you hide the tight case at 768 px, where text and columns are most cramped.
- Desktop at the breakpoint or a typical width. A 1280 px frame matches the
80embreakpoint. Many teams add a 1440 px frame to show how the layout behaves when it is wider than the content's maximum width.
A rule that helps: frame at the lower edge of a range, then test the upper edge. The lower edge is where the layout has the least room, so problems appear first. The upper edge is covered in the testing chapter.
Set up the frame in your design tool
Setting up each frame the same way saves rework later. In Figma, the steps are these.
- Create three top-level frames on one page:
Mobile / 360,Tablet / 768,Desktop / 1280. Put the width in the name so anyone can read it from the layer list. - Give each frame a layout grid. Use a column grid that matches your CSS: for example 4 columns on mobile, 8 on tablet, and 12 on desktop. Set the margins (16 px, 32 px, and centered with a max width) and the gutter (16 px, 24 px, 24 px).
- Set the height to hug the content. A frame's height is not a design decision, because pages scroll. Use a fixed height only for the first screen when you need to check what is visible without scrolling.
- Build the content with auto layout. Use "fill container" for items that should stretch and "hug contents" for items that should size to their content. This mirrors how fluid CSS behaves.
- Set constraints on children (left and right, or scale) so that resizing the frame behaves the way the browser does.
If you use components, create variants for each frame, such as Card / mobile and Card / tablet. Link the variant to the frame it appears in. Components that appear across frames should differ only in the properties that change, such as column count or padding.
Record breakpoints as tokens
The three widths must live in one place that both designers and developers read. Store them as named design tokens:
{
"breakpoint": {
"tablet": { "value": "48em", "px": 768 },
"desktop": { "value": "80em", "px": 1280 }
}
}Mirror the same names in the design tool, as variables or as the frame names above. There is no mobile entry because mobile is the base.
CSS custom properties cannot be used inside a media query condition. @media (min-width: var(--bp-tablet)) does not work, because var() is resolved on elements, and a media query is not attached to an element. You have three options:
- Generate the CSS from the token file with a build step.
- Write the values by hand and keep a comment naming the token.
- Use a preprocessor variable that compiles away before the browser sees it.
Whichever you choose, change the number in one place only.
Make sure the page can actually use the frames
Frames only match the browser if the page lays out at the device width. Without the viewport tag, a phone assumes a wide virtual viewport and shrinks the page, so your min-width: 48em query never matches as designed.
<meta name="viewport" content="width=device-width, initial-scale=1">Put this in the <head> of every page. Do not add maximum-scale=1 or user-scalable=no, because they stop users from zooming, which is an accessibility failure.
Gotchas and edge cases
- Scrollbars count. On desktop browsers with classic scrollbars, the media query width includes the scrollbar, but the space your content has does not. A 1280 px window may give you about 1265 px of layout. If your desktop frame looks tight at exactly 1280 px, allow for this.
- Frames are not exhaustive. A window at 1000 px is between the tablet and desktop frames. It uses the tablet layout, stretched. Check that it still looks acceptable. If it does not, a breakpoint is missing, and the next chapter explains how to find it.
- Zoom changes the width. Zooming to 200% at a 1280 px window gives an effective width of 640 px, and the mobile layout applies. This is expected and is useful for checking the mobile frame on a desktop.
- Landscape phones. A phone turned sideways can be 700 to 900 px wide and falls in the tablet range, even though it is short. Do not assume tablet means tall.
- Too many frames. Each extra frame doubles the maintenance work for every screen. Start with three, and add one only when the content demands it.
- Frame and CSS drift. If someone changes
48emto50emin CSS and not in the design, the tablet frame no longer matches. Treat the token file as the source of truth, and review it whenever a breakpoint changes.
A quick check of your setup
Before moving on, confirm each of these:
- Each frame is named with its width.
- Each frame has a column grid that matches the CSS grid.
- The tablet and desktop frames sit at the lower edge of their ranges.
- The breakpoint values are in a token file and not scattered through stylesheets.
- The viewport meta tag is on every page.
Exercise
Your tablet frame is 768 px wide and your CSS uses @media (min-width: 48em). A teammate sets html { font-size: 20px; } and says the tablet layout will now begin at 960 px. Are they right? Also, explain why the mobile frame needs no media query.
Show answer
They are wrong. In media queries, em is based on the browser's default font size (16 px), not on the page's root font size, so 48em stays 768 px. The mobile frame needs no media query because mobile-first CSS uses the base styles for the narrowest layout, and the min-width queries add changes only as the width grows.
Exercise
A phone has a 1080 px wide screen and a device pixel ratio of 3. What width should the mobile frame be, and which frames or CSS ranges apply to this phone in portrait?
Show answer
The viewport is 1080 / 3 = 360 CSS pixels, so design the mobile frame at 360 px. In portrait it falls below 768 px, so only the base (mobile) styles apply.