Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force div to scroll if the text overflows HTML/CSS?

So I have a div tag to sort of draw boxes around various sections, and of course make actual sections.

In one of the sections, there is more text than can be held in the div tag, so I want to for the text within the div tag to have a scroll bar to make it so the text doesn't overflow outside of the box.

How would I do that?

like image 447
Alper Avatar asked Jul 19 '11 18:07

Alper


2 Answers

Add width and height CSS properties to the div, as well as overflow:auto

If you add overlow:scroll, the scroll bars will be always visible.

If you want to have only horizontal scroll, add white-space:nowrap to the element inside of the div.

like image 115
Emil Avatar answered Oct 18 '22 21:10

Emil


Use the following:

div {
    overflow: scroll;
}

If you want them to scroll only in one direction, you can use the overflow-x and overflow-y properties.

like image 20
fletom Avatar answered Oct 18 '22 22:10

fletom