开发者

CSS - creating a div with content that is a set height

I was wondering if there is a way with CSS to set the height of a div and to have that height stay the same even if content goes inside that div ... instead of pushing it down it stays the same.

For example, i want to use jquery slidedown and slide up functions, but i dont want the rest of the content to slide, so if i put a div with a set height just outside the conten开发者_JAVA技巧t i want to slide, then the height will stay the same.

Cheers,


You can use the height attribute to specify the height of the div, and you can prevent content from expanding outside of it by setting overflow:hidden;

Code:

#wrapper {
    height: 20px;
    background-color: orange;
    overflow:hidden;
}

<div id="wrapper">
    content<br/>
    content<br/>
    content<br/>
</div>


Sounds like you want the max-height property, although that's not supported in IE6 (like that matters anymore).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜