开发者

Simple HTML / CSS Questions - Height & Screen Resolution

I need to make a div have a certain height, it has a repeating image in it and I want it to take up the entire screen no matter what the users screen resolution is. Height auto depends on the content so do I need to use ja开发者_JAVA技巧vascript in order to achieve my goal? Or can I use something with a "clear:both;" property on it in order to always stretch the div to the bottom? I would really like to avoid javascript.


As long as the parent container (like body or html) has 100% height, then the div should also. So

html, body{
    height:100%;
}
div{
    height:100%;
    width:100%;
    border:1px solid red;
}

Example: http://jsfiddle.net/jasongennaro/Jm8Mt/

Of course, your div would have a class... example was just for show


Giving the div 100% height and width will make it take up the entire of the window.

#fullscreen {
height:100%;
width:100%;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜