Sub topic 10
Responsive breakpoints
This chapter assumes you can read CSS media queries, open DevTools, and have a design file with more than one frame size (for example mobile, tablet and desktop). You should also know how to set up a fair comparison, as covered earlier in this tutorial.
What a breakpoint check covers
A breakpoint is a viewport width at which the layout changes, such as a three-column grid becoming one column. A responsive check confirms two things:
- Each designed layout looks right at its designed width.
- The page behaves sensibly at every width in between, where no design exists.
Designers usually supply a few frames, such as 375, 768 and 1280 pixels. Real users have other widths, so the second part matters as much as the first.
Step 1: List the breakpoints
Before you test, write down the widths the design defines and the widths the code uses. Search the stylesheet for @media rules. If the code switches at 800px but the design says 768px, you have already found a discrepancy.
Step 2: Check each design width
Use DevTools device mode and type the exact width. Compare against the matching frame. Look at column count, order of content, navigation pattern (full menu or hamburger), image size and font size.
Step 3: Sweep the widths in between
Drag the viewport edge slowly from narrow to wide. Watch for these common errors:
| Symptom | Likely cause |
|---|---|
| Horizontal scrollbar appears | A fixed-width element or image wider than its container |
| Text overlaps or is clipped | Fixed heights on text containers |
| Layout jumps at an odd width | Breakpoint in code differs from the design |
| Large empty gaps | Max-width or padding that never scales down |
| Tap targets too close together | Desktop spacing kept on small screens |
Also test just below and just above each breakpoint, for example 767 and 768. Off-by-one mistakes with max-width and min-width appear here.
Step 4: Find overflow quickly
If a horizontal scrollbar appears, run this in the DevTools console. It lists elements that extend past the viewport.
const vw = document.documentElement.clientWidth;
const offenders = [...document.querySelectorAll('body *')].filter(
(el) => el.getBoundingClientRect().right > vw + 1
);
console.log(offenders);Hover each logged element in the console to highlight it on the page.
Exercise
Exercise
The design shows layouts at 375px and 1280px. The stylesheet changes from one column to three columns at 1024px. At 1000px you see a horizontal scrollbar. What do you check and record?
Show answer
Check the stylesheet breakpoints against the design, since 1024px is not a designed width, so confirm with the designer whether the layout at 1000px is intended. Then run the overflow script at 1000px to find the element wider than the viewport. Record the width (1000px), the symptom (horizontal scroll), the offending element, and the breakpoint mismatch, so the developer can fix either the overflow or the breakpoint.