I find that the scroll bars (disabled or enable) will show up on the sides of the div despite whether or not the element has reached its max length. Just by putting overflow: value; it will automatically display them. How do I make it so that the scroll bars will only show when the element has reached it's max height?
Asked
Active
Viewed 1.2k times
13
-
I can only guess, but are you trying to build a wysiwyg editor? If so I would recommend you changing from div to an iframe as the stage object. Easier to handle, [here](http://stackoverflow.com/questions/5059976/maintaining-aesthetic-scroll-in-contenteditable-div/5063142#5063142) – Cu7l4ss Aug 25 '11 at 12:35
2 Answers
24
Using overflow: auto should only produce scrollbars when the height is exceeded.
div.scrollbars {
max-height: 100px;
overflow: auto;
}

D_V
- 416
- 3
- 16
3
You should be able to use
overflow: auto
In your style. This should only add the scroll bars if they are necessary. See http://www.w3schools.com/cssref/pr_pos_overflow.asp

Aleks G
- 56,435
- 29
- 168
- 265