Horizontal scroll on product page - mobile version

Topic summary

Mobile product pages showed a slight horizontal scroll on small screens because the media container exceeded the viewport. Applying overflow-x: hidden to .grid__item fixed mobile but broke the sticky product info on desktop, so a targeted mobile-only solution was needed.

Early CSS tweaks (desktop padding, hiding overflow on .product-media-container) didn’t resolve the mobile overflow. A more effective approach in section-main-product.css under @media (max-width: 749px) set the slider to fit the viewport: .product__media-wrapper slider-component { width: 100%; margin: 0 } and .product__media-wrapper .product__media-item { margin-left: 0 }.

Remaining issues included a slight left overlap and images cropping on the right during swipe. Adding .product__media-wrapper slider-component .product__media-list { scroll-padding-left: 0 !important; } removed the overlap/cropping and eliminated horizontal scroll, while preserving desktop sticky behavior.

Outcome: Issue resolved with mobile-specific CSS changes; no further action requested. Screenshots were used to illustrate overflow and overlap during the discussion.

Summarized with AI on December 21. AI used: gpt-5.

Hi there,

I have the horizontal scroll issue on my product pages on mobile screens, the media container seems to be wider than the viewport.

I tried to use the common ‘overflow: hidden’ option but that messes up the sticky product information on desktop version.

Could someone check which parent needs editing to fix this width issue?

Any help would be greatly appreciated, will buy you a coffee :folded_hands:

https://muzzamazza.com/products/domino-blue
pass: tiampa

Hello @muzzamazza
Go to online store ---------> themes --------------> actions ------> edit code------->assets-----> section-main-product.css
add this code at the end of the file.

@media screen and (min-width: 750px) {
.product-media-container {
padding: 10px !important;
}
}

result

If this was helpful, hit the like button and accept the solution.
Thanks

Thanks for your reply Rahul, however I don’t think you understood my question.

The problem I have is on mobile screens, the entire page can scroll left and right (overflow-x) slightly.

I want to find the container/parent where the overflow is the problem and fix that width.

I tried to add

.grid__item { overflow-x: hidden; } in theme.liquid but that stops the product information being sticky on desktop as i scroll and I very much need that to work.

Hi @muzzamazza , I hope you are doing well.

  1. Go to Online Store → Theme → Edit code.
  2. Open your theme.liquid file
  3. In theme.liquid, paste the below code before

If my reply is helpful, kindly click **like** and mark it as an **accepted solution.**

Thanks!

Hi Steve,

I don’t need spacing between the images on desktop, I need to get rid of the overflow-x when viewing my product on mobile.

Adding the below in the theme liquid worked but then created the problem on desktop where the sticky product information stopped being sticky. So I need another solution that fixes the main media container/parent with the problematic overflow.

.grid__item { overflow-x: hidden; } ![horizontal scroll.JPG|950x1777](upload://62WVgOjosMvOKyVQv8322J6C88M.jpeg)

@muzzamazza , can you try the below code:

@media (max-width: 749px) {
  .product-media-container {
    overflow-x: hidden;
  }
}

If my reply is helpful, kindly click like and mark it as an accepted solution.

Thanks!

Nope, doesn’t work unfortunately

@muzzamazza , I see, try the below code:

@media (max-width: 749px) {
  .product-media-container {
    overflow-x: hidden; /* This will prevent Prevent horizontal scroll */
    max-width: 100%; /* This will check and Ensure container does not exceed viewport width */
  }

  .grid__item {
    overflow-x: hidden; /* This will prevent horizontal scroll on grid items */
    max-width: 100%; /* This will check and ensure grid items fit within the container */
  }
}

@media (min-width: 750px) {
  .sticky-product-info {
    position: sticky;
    top: 0; /* Adjust as needed */
  }
}

Hello @muzzamazza

If you are still facing the same issue even after applying below solutions, please try by following this steps:

  1. Go to admin > online store > edit code.

  2. In code directory, find the file named “section-main-product.css” and open it.

  3. Copy below given code and paste it at the end of the file that mentioned above.

@media (max-width: 749px){
   .product__media-wrapper slider-component{
     width: 100%;
     margin: 0 !important;
   }
   .product__media-wrapper .product__media-item {
     margin-left: 0 !important;
   }
}
  1. Don’t forget to save the file after making changes.

Hope this solution works best for your issue than other solutions.

Hya Parth,

ah this is working pretty well, there’s just one issue → scrolling through the images there’s a slight overlap on the left after each one slides in.

Ok this is working pretty well, it would be even better if the images actually fit inside the container as they are currently being cropped on the right side (you can see by sliding through to the next image that it’s actually wider than the screen)

Thanks for al your help on this so far

You need to add below css rule with the css which you paste previously that i’ve mention.

in the media rule @media (max-width: 749px), add this rule:

.product__media-wrapper slider-component .product__media-list {
  scroll-padding-left: 0 !important;
}

By this your issue will be fixed.

1 Like

@muzzamazza , try the below code:

.product__media-wrapper slider-component .product__media-list {
  scroll-padding-left: 0 !important;
}

If my reply is helpful, kindly click like and mark it as an accepted solution.

Thanks!

LEGEND!

Thank you :folded_hands: