开发者

Footer height based on screen size

I would like to create a footer which is relative to the content (so not fixed), but fills the rest of the screen. So for example, on my larger monitor, the footer would start in the same place, but fill up 100px (for example). On a开发者_运维百科 smaller monitor, it only needs to fill up 75px. I tried using 100%, but it causes the page to be really big and the user can scroll down and fill the entire screen with the footer. Is there a way to get it to be a bit more reasonable size, so that it just about fills the bottom of the screen? My current code is this:

.footer
{
    position:relative; //can't be fixed as content might overlap if extended    
    height:100%;
    width:100%; //fill the entire screen horizontally
    bottom:0px;
    margin-top:345px; //used to make sure content doesn't overlap
}


I was struggling with something similar and the trick I found to solve it was to make sure to set body and html to min-height:100% as well as then have content and all other divs equal 100%.

html {
    min-height: 100%;
}
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}
#content {  
    min-height: 100%;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜