How to show scrollbars of content-edited div only when it reaches its maximum height?

I find that scrollbars (disabled or enabled) will appear on the sides of the div, regardless of whether the element has reached its maximum length. Just putting overflow: value; it will automatically display them. How to do this so that scrollbars are displayed only when the element reaches its maximum height?

+8
html css
source share
2 answers

Overflow usage: auto should create scrollbars only when the height is exceeded.

div.scrollbars { max-height: 100px; overflow: auto; } 
+15
source share

You should be able to use

 overflow: auto 

In your style. It is only necessary to add scrollbars if necessary. See http://www.w3schools.com/cssref/pr_pos_overflow.asp

+3
source share

All Articles