Is it possible to prevent just horizontal scrolling when overflow-x is hidden?

Andrew LeClair picture Andrew LeClair · Apr 15, 2010 · Viewed 9.3k times · Source

I have a web page that has content which extends past the right edge of the browser window. I set overflow-x: hidden on <body> to turn off the bottom scrollbar, but I can still scroll horizontally with the trackpad, which is not what I want.

Is there any way to prevent the browser from scrolling horizontally?

As a side note: Safari 4.0.4 only scrolls horizontally sometimes, and the scrolling feels "sticky" and "jumpy," whereas Firefox always smoothly scrolls horizontally.

Answer

Manuel Bitto picture Manuel Bitto · Apr 15, 2010

you could try to set in CSS:

html{
  overflow-x: hidden;
}

instead of use body selector. I tried that and works in firefox.