RESPONSIVE

Why does my mobile website scroll sideways?

Something is wider than the screen: find that element with Sitepeel’s free responsive checker, see why it can’t shrink, and fix its CSS instead of hiding the overflow.

A pricing card extends beyond a mobile viewport, then wraps correctly inside the same screen.
Illustration: Find the element crossing the viewport edge, then fix its sizing or wrapping.

In short

  • Sideways scroll means one element is wider than the viewport
  • Find it with a console snippet, then check its parent
  • Usual causes: fixed widths, flex or grid children, long words, big media
  • Don’t hide it with overflow-x: hidden on the whole page
On this page7
  1. Step by step
  2. Reproduce it at a known width
  3. Find the element that overflows
  4. Common causes and fixes
  5. Example: a product row that won’t shrink
  6. Check the fix
  7. Questions

Step by step

  1. 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.

  2. Find the overflowing element

    Run the snippet below, then inspect the first unexpected element and its parent.

  3. 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
The free responsive checker on stripe.com: six screens side by side, and the problems it found.
Responsive viewer extension in the Sitepeel interface
Responsive viewer extension in actionExplore the tool

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.

find-overflow.jsJavaScript
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.

The four usual causes of sideways scroll on phones.
Common causes and focused fixes
CauseWhat to inspectPossible fix
Fixed-width cardwidth and padding on the cardwidth: 100%; max-width: 600px; box-sizing: border-box
Flex or grid childAutomatic minimum sizemin-width: 0 on the child that must shrink
Unbroken URL or codeText wrapping in the blockoverflow-wrap: anywhere
Oversized mediaIntrinsic image or video sizemax-width: 100%; height: auto
Data tableWhether every column must showA 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.cssCSS
.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.

TAKE A CLOSER LOOK

Your next starting point is already on the web.

Inspect it. Understand it. Build something of your own.

Add to ChromeFree installTry the free tools