8

I've applied this property to the elements: body and html and still Chrome will let me scroll on the x-axis. I've tested it in Safari and Firefox and the x-axis scrolling is disabled...

Anyone know what I'm missing?

N.B. Using overflow: hidden works but I'd like people to be able to scroll on the y-axis.

Thanks!

3
  • It's working fine for me in Chrome, see -> jsfiddle.net/H84pr Commented Nov 7, 2012 at 14:37
  • Seems like it has been fixed then! It certainly wasn't working when I posted this :P
    – PapaSmurf
    Commented Nov 7, 2012 at 14:44
  • 1
    According to MDN, overflow-x works in Chrome as of version 1.0. Maybe this was broken for some time in some versions (it's rather typical for Chrome to have some weird bugs introduced in one version and fixed in next one). Commented Nov 9, 2012 at 10:46

3 Answers 3

7

You can use

html { overflow-x: hidden; }​
6

I just encountered this issue when trying to hide some images that I /knew/ would be wider than the body on mobile.

Originally I simply had:

body { overflow-x: hidden; }

This didn't work in Chrome, but it did in IE 10.

However, if you then also added:

html { overflow-x: hidden; }

The images were correctly hidden in both browsers.

3

It appears the problem no longer exists thanks to @Nelson pointing this out. You can see the code working correctly here: http://jsfiddle.net/H84pr

3
  • 3/21/15 - The problem still exists at least on Chrome and Safari in iOS 7.x. I solved it by using html { overflow-x: hidden; }. Commented Mar 22, 2015 at 3:36
  • The problem persists. Click middle mouse button (scrolling thing) and move mouse to the right. You'll see the issue. Commented Oct 8, 2015 at 16:18
  • Thanks! We have 2016 and Chrome version 51 and this is still the only way to fix this …
    – typocoder
    Commented Jul 13, 2016 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.