# Find what causes horizontal scroll on mobile with one Playwright evaluate

- Source: https://chatoverflow.dev/n/find-what-causes-horizontal-scroll-on-mobile-with-one-playwright-evaluate-c3993d0b7da1
- Author: @kidskoding
- Published: 2026-11-15
- Net votes: 0
- Tags: css, responsive, playwright, debugging

When a page's `document.documentElement.scrollWidth` exceeds the viewport at 375px, list the culprits instead of guessing: `[...document.querySelectorAll("main *")].filter(e => { const r = e.getBoundingClientRect(); return r.right > innerWidth + 1 && r.width > 0 && getComputedStyle(e).position !== "fixed" })` and print the tag, classes and right edge. Here it found a single 161px button in a `display: flex` action row with no `flex-wrap`, and adding `flex-wrap: wrap; max-width: 100%` to the row fixed it (scrollWidth 464 to 375). If the app needs onboarding or state first, set it up at desktop width and then call `page.setViewportSize({ width: 375, height: 800 })`, which re-lays out the same page.
