On this page7
Step by step
Reproduce at a known width
Open the failing route at the CSS width where it scrolls, in the same state, such as an open menu.
Find the overflowing element
Run the snippet below, then inspect the first unexpected element and its parent.
Fix and retest nearby widths
Change the responsible CSS, reload, then check slightly narrower and wider widths, menus and focus.
Reproduce it at a known width
- Record the CSS viewport width, not the phone name or screen resolution
- Keep the same state: a closed menu and an open menu are different tests
- In Responsive viewer, keep one narrow preview beside a wider one
- Change the viewport size to test; the scale slider only resizes the preview
- Turn off synchronized scrolling to inspect different positions

Find the element that overflows
Run this in the DevTools console of the affected page, at the scroll position where the problem shows. It compares the page width with the viewport and lists elements past the right edge.
Inspect the first unexpected element and its parent. Turn off its width or min-width in DevTools: if the scroll goes away, you found the cause.
const viewport = document.documentElement.clientWidth;
console.log({ viewport, scrollWidth: document.documentElement.scrollWidth });
const suspects = [...document.querySelectorAll('body *')].filter(el => {
const r = el.getBoundingClientRect();
return r.width > 0 && r.right > viewport + 1;
});
console.log(suspects);Common causes and fixes
A 600px panel can’t fit a 360px screen. Swap fixed widths for a max-width, and let flex or grid children shrink.
| Cause | What to inspect | Possible fix |
|---|---|---|
| Fixed-width card | width and padding on the card | width: 100%; max-width: 600px; box-sizing: border-box |
| Flex or grid child | Automatic minimum size | min-width: 0 on the child that must shrink |
| Unbroken URL or code | Text wrapping in the block | overflow-wrap: anywhere |
| Oversized media | Intrinsic image or video size | max-width: 100%; height: auto |
| Data table | Whether every column must show | A labeled wrapper with overflow-x: auto |
Example: a product row that won’t shrink
A thumbnail, a long name and a buy button share one row. On a narrow screen the name holds the row open and pushes the button off screen. Let the text column shrink, wrap long words and stack the button.
.product-row {
display: grid;
grid-template-columns: 64px minmax(0, 1fr) auto;
gap: 12px;
}
.product-copy { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) {
.product-row { grid-template-columns: 64px minmax(0, 1fr); }
.product-action { grid-column: 1 / -1; }
}Check the fix
- Test the failing width, plus one slightly narrower and one wider
- Open menus, trigger errors and tab through the controls
- Make sure focused buttons stay inside the visible area
- Check spacing with Measure
- Confirm the main flow in the target mobile browser
Questions
Why is my website wider than the screen on mobile?
One element is wider than the viewport. Common causes are a fixed width, a flex or grid child that won’t shrink, a long URL or oversized media. The console snippet above lists the suspects.
Should I use overflow-x: hidden on the body?
Not as a first fix. It hides the scrollbar but can leave content unreachable and focused buttons off screen. Fix the element that overflows.
Should I remove all horizontal scrolling?
No. A table or gallery may scroll inside its own region on purpose. The problem is unexpected page-wide scrolling, or content people can’t reach.
Does a phone mockup fix responsive CSS?
No. A frame helps you picture a device. Fix the CSS in the source project and reload the preview to check it.



