页脚背景总是在底部

时间:2013-02-21 12:55:06

标签: html css

我的页面页脚出现问题。我希望页面底部始终有一个页脚(背景)。如果浏览器变大,他的身高会增长。我见过stickfooter但在这种情况下高度不会改变。谢谢。

http://img688.imageshack.us/img688/2499/layoutus.png

以下是图片的链接以便更好地解释。

3 个答案:

答案 0 :(得分:1)

将正文的背景颜色设置为页脚的背景颜色,将内容包装在div中,并使用内容区域的首选背景颜色。

答案 1 :(得分:1)

在你的照片中,身体保持不变,只有页脚在增长;要实现这一点,你必须为你的身体指定一个固定的高度。

如果你想让它们都成长,那就是代码:

HTML

<div id="main">I'm the body</div>
<div id="footer">I'm the enlarging footer</div>

CSS

body, html{
    height: 100%;
}

#main{    
    background:silver;
    min-height: 80%;
    min-width: 100%;
    height: 80%;
}
#footer{    
    background: green;
    position: fixed;
    bottom: 0;
    min-height: 20%;
    min-width: 100%;
}

DEMO http://jsfiddle.net/TyhLL/

答案 2 :(得分:-1)

我也经历过同样的问题

sticky footer the flexibleway

这篇文章可能对你很有帮助。

相关问题