34

Is it possible to achieve only horizontal overflow in CSS 2.1?

overflow: auto;

Will cause a block element to have both horizontal and vertical scrollbars. I want a block element (let's say <div>) which will display only horizontal scrollbars. How do I do that?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Richard Knop
  • 81,041
  • 149
  • 392
  • 552

3 Answers3

50

Try overflow-x: auto;

It even works in IE6!

Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
  • For FF you can use `overflow: -moz-scrollbars-horizontal;` -- I'm not sure about Webkit. – Cᴏʀʏ Aug 27 '09 at 02:59
  • Although Mozilla claims that it will work in FF as low as version 1.5. https://developer.mozilla.org/en/CSS/overflow-x – Cᴏʀʏ Aug 27 '09 at 03:01
6

I tried overflow-x: hidden; and that worked for me.

EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
Bikram Shrestha
  • 2,010
  • 24
  • 22
5
overflow-x: clip;

Was what I needed

Fractal Mind
  • 405
  • 4
  • 10