开发者

Is there a way to set vertical scrollbar for a div?

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 he开发者_如何学Pythonight, 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>


only vertical scroll

<div style="overflow-y:auto;"></div>


do this in css

div {overflow: scroll}

edit: What's with all the inline styles guys :-(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜