Fixing That Pesky Mobile Horizontal Scroll on Shopify (Especially for Stretch Theme Users!)

Hey fellow store owners! Let's talk about something that can really frustrate both you and your customers: that annoying horizontal scroll on your mobile site. You know, when you swipe left or right, and the whole page shifts just a little bit, even though there's nothing else to see? It's a common headache, and it often points to an element on your page that's just a tad too wide for the mobile viewport.

Recently, we saw a great discussion pop up in the Shopify community about this very issue, specifically for users of the Stretch theme. Our friend siva_fds kicked things off, asking for help with a horizontal scroll problem on their mobile site. They even shared a preview link and password, which is super helpful for diagnosing these kinds of things (kudos, siva_fds!).

The Quick Fix (and Why You Should Be Careful)

When you first encounter this, a common suggestion you might see floating around, like the one from big-bulk-discount in the thread, is to add some CSS to your body and html elements:

body,html {
overflow-x: hidden !important;
width: 100%;
}

Now, this does often hide the scrollbar. However, as Ecom_swift_LLC and HotspotStudio wisely pointed out, this is usually just masking the symptom, not fixing the cause. Even worse, applying overflow-x: hidden globally to html and body can actually break other important elements on your page, like position: sticky headers. Imagine your beautifully designed sticky header suddenly not sticking anymore – not ideal!

Finding the Real Culprit: Your Detective Tools

So, if you shouldn't just hide it, how do you find what's causing the problem? This is where your browser's Developer Tools (DevTools) become your best friend. Ecom_swift_LLC shared a fantastic little console command that can help you pinpoint the exact element overshooting your viewport:

document.querySelectorAll('*').forEach(e=>{if(e.getBoundingClientRect().right>document.documentElement.clientWidth)console.log(e)})

Just open your DevTools (usually F12 or right-click -> Inspect), switch to mobile view, go to the Console tab, paste that line, and hit Enter. It'll log any element that's wider than your screen.

HotspotStudio took this a step further and did some excellent detective work on siva_fds's store. They quickly identified that the overflow wasn't the header at all, but specifically the announcement bar section above it, the one with the slider.

Screenshot of mobile horizontal scroll issue

The Specific Culprit: Carousel Arrow Tap-Areas

HotspotStudio's updated diagnosis was incredibly precise. It turns out, the issue wasn't the announcement bar itself, but the carousel arrows inside it. Specifically, the theme was giving a ::before pseudo-element to the .tap-area class. This pseudo-element, designed to make the tap target larger for mobile users, was 36x36 pixels. With the next button sitting flush against the right edge of the viewport, half of this invisible box was hanging off the page, creating that horizontal scroll. Sneaky, right?

DevTools showing announcement bar overflow

DevTools showing tap-area pseudo-element

Here's the code for that pseudo-element:

.tap-area::before {
content: "";
width: var(--tap-area-size);
height: var(--tap-area-size);
left: calc(50% - var(--tap-area-size) / 2);
position: absolute;
}

The Recommended Fix: Targeted & Safe CSS

Since the ::before pseudo-element has content: "" and isn't visible on its own, clipping it won't affect how your announcement bar looks or functions. The best approach here is to target the specific section causing the overflow, rather than hiding it globally. This way, you keep your sticky elements working and address the problem precisely.

Step-by-Step Instructions:

  1. Identify the Section Class: In this case, for the Stretch theme's announcement bar, the class identified was .shopify-section--announcement-bar. You can always confirm this by inspecting the element in DevTools.
  2. Add Custom CSS:
    • From your Shopify admin, go to Online Store > Themes.
    • Find your current theme, click Actions > Edit code.
    • Alternatively, for simpler CSS, you can often go to Online Store > Themes > Customize, then click Theme settings (the gear icon on the left sidebar) and look for a Custom CSS or Advanced CSS section.
  3. Apply the Overflow Property: Add the following CSS snippet to your custom CSS area. While overflow-x: hidden; works, Ecom_swift_LLC gave us an even safer option: overflow-x: clip;. This property works similarly to hidden but is explicitly designed not to create a new formatting context, which can sometimes interfere less with position: sticky elements.
.shopify-section--announcement-bar {
overflow-x: clip;
}

This tells the browser to simply clip anything that extends beyond the horizontal boundaries of that specific announcement bar section. Since the oversized tap-area pseudo-element is invisible anyway, you lose nothing visually, but gain a perfectly smooth mobile experience.

A Crucial Testing Tip

Ecom_swift_LLC also shared a really important testing note: always test your fix on actual iOS Safari, not just your browser's DevTools mobile emulator. iOS is known for being stricter about things like "rubber-band bounce" and can sometimes still show a hint of scroll even if Chrome's emulator looks perfectly clean. So, grab your iPhone or iPad and give it a real-world test!

By taking a targeted approach to these kinds of mobile responsiveness issues, you're not just patching a problem; you're building a more robust and user-friendly store. A smooth mobile experience is absolutely critical for conversions and keeping your customers happy, so tackling these details head-on is always worth the effort. Big thanks to HotspotStudio, Ecom_swift_LLC, and big-bulk-discount for their insights in the community discussion!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases