The power of a div to scroll if text overflows with HTML / CSS?

So, I have a div tag for sorting drawers for drawing around different sections and, of course, for creating real sections.

There is more text in one section than can be held in the div tag, so I want the text in the div tag to have a scroll bar so that the text does not overflow outside the box.

How can I do it?

+6
source share
2 answers

Use the following:

div { overflow: scroll; } 

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

+16
source

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

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

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

+16
source

Source: https://habr.com/ru/post/893096/


All Articles