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.
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:
overflow
overflow-x
overflow-y
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
If you want vertical scrollbar then
<div style="overflow-y:auto;overflow-x:hidden"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With