Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make the scrollbar on a div only visible when necessary?

People also ask

Is similar to scroll but it adds scrollbars only when necessary?

overflow: auto The auto value is similar to scroll , but it adds scrollbars only when necessary: You can use the overflow property when you want to have better control of the layout. The overflow property specifies what happens if content overflows an element's box.

How do I make a div not scrollable?

As for preventing scrolling on the div, all you need to apply on the footer is overflow: hidden; and that should do the trick. Actually margin:0 auto; is not going to help with position:absolute;.


Use overflow: auto. Scrollbars will only appear when needed.

(Sidenote, you can also specify for only the x, or y scrollbar: overflow-x: auto and overflow-y: auto).


try this:

<div style='overflow:auto; width:400px;height:400px;'>here is some text</div>

try

<div style='overflow:auto; width:400px;height:400px;'>here is some text</div>

try

<div id="boxscroll2" style="overflow: auto; position: relative;" tabindex="5001">

Change overflow property of CSS block to auto.

overflow: auto;

It will automatically add a scrollbar to the left only when needed.