Reputation: 5104
I put a empty content div into a td tag in a table. It shows as there is only one line in div. If I set the height of the div, when I input more content than it's height, it still keep the same size as it was. How to add a vertical scrollbar when content need to consume more space in the div? Thanks.
Upvotes: 16
Views: 84853
Reputation: 545
If you want vertical scrollbar then
<div style="overflow-y:auto;overflow-x:hidden"></div>
Upvotes: 1
Reputation: 86872
Automatically show scroll bars when content is greater than height and width like this:
<div style="overflow:auto;"></div>
OR
Show scroll bars at all times like this:
<div style="overflow:scroll;"></div>
Below is some reference for CSS overflow properties:
Upvotes: 22
Reputation: 1747
Use overflow
, or overflow-y
: auto
| hidden
| scroll
| visible
<div style="max-height:100px; overflow-y:auto"> ... </div>
or
<div style="max-height:100px; overflow-y:scroll"> ... </div>
NOTE: overflow
supported since CSS2, but overflow-y
- CSS3, Opera 9.6, Safari 3.1
Upvotes: 12
Reputation: 4792
do this in css
div {overflow: scroll}
edit: What's with all the inline styles guys :-(
Upvotes: 0