Forum Moderators: not2easy

Message Too Old, No Replies

Scroll Bars in a DIV

         

inveni0

4:55 pm on Oct 5, 2006 (gmt 0)

10+ Year Member



Is there a way to create a DIV class that will auto enable scroll bars within that div if the text inside requires more than 'X' amount of height?

Robin_reala

4:58 pm on Oct 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep:

div {
overflow: auto;
height: 500px;
}

Obviously change the selector to select your particular div, and the height to what you want.

inveni0

6:42 pm on Oct 5, 2006 (gmt 0)

10+ Year Member



Awesome, thanks!

Robin_reala

9:13 pm on Oct 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As an addendum: that'll also create a horizontal scrollbar. The current working draft of CSS3 box model module specifies overflow-x and overflow-y [w3.org] which let you dictate overflow for specific axes. This was first introduced by IE, pulled into the current spec, then added into Gecko in time for Firefox 1.5. As it's still in working draft you shouldn't expect stability, but w3 don't usually change specs if there's a couple of interoperable implementations.