Website looks fine on desktop but broken on mobile
The reviewer is on a laptop, the visitor who hits the bug is on a phone. Layout bugs that only exist at one width, how to find them in five minutes, and what emulation cannot show.
- Published
- Reading time
- 5 min read
Key takeaways
- Review every change at a phone width and at a desktop width; most layout bugs live at the width nobody checked.
- Sideways scrolling is the quickest sign of a mobile bug, and a console snippet finds the element that causes it.
- Keep separate baselines for desktop and mobile, because one says nothing about the other.
- Device emulation runs Chromium; check key flows on a real iPhone as well.
A page at 390 pixels wide and the same page at 1440 pixels are, in practice, two layouts that break in different ways. Many layout bugs that slip through review live at the width nobody checked, usually the phone. Check both widths after every change and keep a separate baseline for each.
Why a site looks fine on desktop but broken on mobile
A site looks fine on desktop but broken on mobile when its layout assumes a wide screen. Fixed widths, missing media queries, a missing viewport tag and long words that cannot wrap all fit on a desktop. At 390 pixels the same elements overflow, overlap or push the page sideways.
Fixed widths and missing media queries
A box set to width: 960px, or a grid of four columns with no rule for small screens, keeps its desktop size on a phone. The page then scrolls sideways, or the browser shrinks everything to fit. Give images and containers max-width: 100%, and add a media query where columns should stack:
.cards {
display: grid;
grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 640px) {
.cards {
grid-template-columns: 1fr;
}
}
MDN’s guide to using media queries covers the syntax and the width ranges.
Why phone-width bugs slip through review
The person who reviews a change usually does it on a laptop, at one width. The visitor who finds the bug is often on a phone, holding it with one hand.
Search sees the phone version too. Google uses the mobile version of a page for indexing and ranking. Content hidden at phone width can be missing for search as well as for visitors.
Layout bugs that only show on mobile
These bugs are invisible at desktop width. Each has a typical cause and a quick check:
| Bug | Typical cause | Quick check |
|---|---|---|
| The whole page scrolls sideways | A long word, URL or price; a fixed-width element | Swipe left on the page; run the snippet below |
| A sticky header or banner covers the CTA | Two fixed elements stacked at the top or bottom | Scroll to the main button at 390 px |
| The menu opens behind content or won’t close | z-index on the header; a script error on touch |
Open and close the menu, then tap a link |
| An image is missing only on phones | A broken small-size source in srcset or <picture> |
Reload at 390 px and watch the network panel |
| Buttons too close to tap | Desktop spacing squeezed into one column | Tap each button in a row of links |
| Text cut off inside buttons or cards | A fixed height on a box whose text now wraps | Read every button label at 390 px |
| The desktop page shrunk to fit | The viewport meta tag is missing | Check the head for name="viewport" |
Two of these have published thresholds. WCAG 2.2 asks for targets of at least 24 by 24 CSS pixels, or enough spacing around smaller ones. The reflow criterion asks that content works at 320 CSS pixels wide without scrolling in two directions.
The viewport tag is a one-line fix, and the meta tag checker shows whether a page has one.
A sticky banner over the main button is the hardest of these to spot, because the button is still in the HTML. Monitoring critical elements explains why present is not the same as visible.
Layout bugs that only show on desktop
Wide layouts fail differently:
- Hover-only menus. A dropdown that opens on hover works with a mouse and needs a click fallback for touch laptops.
- A lonely last card. A grid of four columns with five items leaves one card alone on the last row.
- Stretched images. A hero image sized for 1280 pixels looks soft at 1440 and wider.
- Empty space. Content capped at a narrow width looks unfinished on a large monitor.
- Sticky sidebars. A sidebar fixed in place can run over the footer on short pages.
Find sideways scrolling in ten seconds
Horizontal scrolling at phone width is the quickest sign that something is too wide. Paste this into the browser console at 390 pixels to list the elements that stick out:
const width = document.documentElement.clientWidth
for (const element of document.querySelectorAll('body *')) {
const box = element.getBoundingClientRect()
if (box.right > width + 1 || box.left < -1) {
console.log(Math.round(box.right), element)
}
}
The deepest element in the list is usually the cause; its parents only stick out because it does. Long URLs and email addresses need overflow-wrap: anywhere, and wide tables need a scrolling wrapper.
Check both widths in five minutes
- Open device mode in Chrome DevTools and set the width to 390.
- Reload the page. Some scripts read the width only on load, so resizing alone can hide bugs.
- Scroll the whole page slowly, watching for sideways movement and covered buttons.
- Open the menu, close it, and tap the main call to action.
- Fill one field of every form to see how the keyboard and labels behave.
- Set the width to 320 and scroll once more, for the reflow check.
- Switch to 1440 and repeat steps 3 and 4 with a mouse.
These steps are one part of the post-deploy checklist, which also covers status codes, images and console errors.
Give each width its own baseline
Elements move, collapse and disappear between 390 and 1440 pixels, so a desktop screenshot cannot be the reference for mobile. Treat each width as its own page: capture both, keep a baseline for each, and review both when something changes.
Each width also has its own noise. A cookie banner covers far more of a phone screen than of a desktop one, so its ignore rule may differ. The guide to approving baselines without false positives covers those rules, and the visual regression method without code explains the comparison itself.
What device emulation does not show
Device mode in Chrome is Chromium at a phone width, with touch events and a mobile user agent. It is not Safari on an iPhone. Some bugs only appear in iOS Safari:
- toolbars that appear and hide, so
100vhsections jump or get cut off; - fixed elements that move when the on-screen keyboard opens;
- native date and select inputs that look different from Chrome.
Check sign-up, checkout and contact flows on a real iPhone after larger changes. The section on testing on a real phone in the JavaScript errors guide covers how to see errors there too.
How Rookflare captures both widths
Rookflare’s visual monitoring captures every monitored page twice in Chromium. Desktop is 1440 × 900; mobile is 390 × 844 with touch and a mobile user agent. Each capture is compared with its own baseline, and ignore areas are kept per width. Both captures count as one monitored page. Rookflare does not capture tablet widths, phones held sideways or Safari, so a real iPhone still gets a look after larger releases.
Share this article
Written by
Dalius Pamedytis
CEO of Rookflare
Dalius is the CEO of Rookflare and the engineer who builds it, from the Playwright scanner that captures every page to the dashboard where you review what changed. Day to day he also works on large marketing websites and dashboards, so he has seen how a quiet release can break a checkout button or a sign-up form. He writes about what actually breaks on real websites and the simplest way to catch it before your visitors do.
More from Dalius PamedytisKeep reading
-
Visual monitoring
False positives in visual regression testing: causes and fixes
Day one brings twenty visual alerts, day four a muted channel. The sources of that noise are predictable, and each has a better fix than a higher threshold.
-
Visual monitoring
Visual regression testing without code: baselines in production
Many layout breaks never pass through a pull request: CMS edits, plugin updates, third-party scripts. How screenshot baselines on the live site catch them without a test suite.
-
Visual monitoring
Website looks different after an update: how to find what changed
After a plugin or theme update, the question is what changed and whether it matters. A before and after method that answers both quickly, even without a before screenshot.