开发者

CSS/HTML: Set default container height

Hey, how can i set a default container height on a element?

My example have a div like this:

<div id="container">
text text
</div>

Then i want the height default at 300px; so it gets large even with only this text^.

With DEFAULT i mean also, that if the text exceeds 300px the height should just be bigger like there开发者_StackOverflow中文版 isnt specified a height.


Try using min-height:

#container {
    min-height: 300px;
}

JS Fiddle demo, this features extra css (for aesthetic purposes), but the important part is still the min-height declaration.


your css should be like this:

div#container {
  min-height: 300px;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜