I have defined a tag with a CSS attribute "overflow" set to "scroll". This is giving me both the vertical and the horizontal scroll bars. I only want the vertical scroll bar. What should i do?
To the down voter... please provide a comment as to why you down voted.
Zoidberg
2009-09-09 18:12:45
+3
A:
Try using "overflow-y: scroll;
" instead. It's CSS3, but as far as I know, it's supported by every modern browser (IE6+, FF, Opera, Chrome/Safari/WebKit/etc.).
A quick explanation of the various overflow
/-x
/-y
values, for those not familiar with them:
visible
– The default. Content which does not fit "overflows" the box, usually appearing over or under adjacent content.hidden
– Content which does not fit is "guillotined" — cut off at the edges of the box.auto
– Content which does not fit causes a scroll bar to appear. Does not necessarily cause both scroll bars to appear at once; if content fits horizontally but not vertically, only a vertical scroll bar will appear.scroll
– Similar toauto
, but scroll bar(s) appear whether needed or not. AFAIK, mostly used to prevent centered content from "jumping" if a scroll bar needs to be added to dynamic (e.g. AJAX) content.
Ben Blank
2009-09-09 17:32:44
I have seen one browser that does not support overflow-x, overflow-y, but I can't remember which. Probably an old version of firefox or Opera or something silly like that, so this solution is a good one as well. Only thing is, with overflow-y:scroll, the vertical scroll bar will always be there even if it is not needed.
Zoidberg
2009-09-09 17:36:17
@Zoidberg — IIRC, both FF2 and Opera 9 support it, so an older browser would be my guess as well. And from the original question, I expect an "always-on" scroll bar is exactly what he wants. Of course, it works perfectly well with `auto`, `hidden`, or `visible`, too.
Ben Blank
2009-09-09 17:41:00
@Ben Blank Yeah, based on his question it sounds like that. I guess my answer is partial to not showing the scroll bar if its not needed because I hate scroll bars. My question is why didn't he accept your answer?
Zoidberg
2009-09-09 17:48:35
@Zoidberg — Perhaps trying to encourage another low-rep user? As long as he's helped, though, it's all good. :-)
Ben Blank
2009-09-09 17:49:56
+1
A:
You could try using the
overflow-y: scroll;
This will give you a vertical scroll-bar...
Kim Andersen
2009-09-09 17:34:45