开发者

Is it possible to force a <div> not to have scrollbars

this may be a very simple question, but is it possible to force a div not to have scrollbars? I have a div that i change the size of dynamically, and would like to force it to be fixed in size. How would 开发者_开发技巧i do this?

Thanks


Use overflow:hidden in combination with the desired width/height.


By default a div will not have scrollbars. It will only gain them if you set the overflow property to a value that adds them. So long as it remains at visible or is changed to hidden the div will be whatever size you specify.

(Note that when overflow is visible, the div will remain at the given size, but the content might escape it.)


Use the Overflow property: set to 'hidden'


Declare a width and height, and then use the overflow property:

overflow: hidden

This will hide the scroll bars. Look at the other options as well.

You could choose which ones you want to display using overflow-x and overflow-y


Use the overflow attribute on CSS as such:

<style type="text/css">
<!--
div.scroll {
height: 600px;
width: 800px;
overflow: hidden;
border: 1px solid #666;
background-color: #ccc;
padding: 8px;
}
-->
</style>

Here's an example I wrote:

http://jsbin.com/orife/edit

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜