html - 尽管 body 高度为 100%,页脚仍然卡在中间页面

标签 html css position css-position

live site

尽管设置了正文 height:100%,但我的页脚仍卡在某些页面(关于、联系方式)的中间页面。我指定了页脚高度,并尝试了 position:fixedposition:absolutebottom:0。似乎没有任何帮助,有什么想法吗?

编辑:尝试“粘性页脚”也不起作用;它将页脚稍微放在中心页面的右侧。

body {
    background: #fff;;
    font-family: london, Arial, sans-serif;
    height: 100%;
}

#container {
    width: 960px;
    margin: 0 auto;
    padding: 60px 0 120px 60px;
}
#footer {
    position: absolute;
    width: 340px;
    margin: 0 auto;
    bottom: 0;
    height: 120px;
}

最佳答案

为您的容器、 fiddle 和下面的代码添加 100% 的高度

http://jsfiddle.net/pJAsF/2/

html, body {
    background-color:#f5f5f5;
    height:100%;
}
#header {
    position:relative;
    background:#333;
    min-height:50px;
}
#container {
    width: 960px;
    margin: 0 auto;
    height:100%;
}
#container p {
    font:2em normal Futura, sans-serif;
}
#footer {
    background-color:#333;
    min-height:50px;
}

<div id="header"></div>
<div id="container">
    <p>Hello</p>
</div>
<div id="footer"></div>

关于html - 尽管 body 高度为 100%,页脚仍然卡在中间页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18370756/

相关文章:

numbers - 检查 number lisp 中偶数位置的偶数

html - 使用 vb.net(Winforms) 创建 html 页面并将 css 文件添加到 html 页面

html - 如何为输入边框设置动画并使其从中心扩展?

jquery - 标题中带有特殊字符的 $.getJson 函数

javascript - 推荐用于网络浏览器的网络开发插件

html - 使用css定位img元素

javascript - 如果隐藏则不需要复选框来启用按钮

java - 样式表不适用于第一个 JSF 页面

css - 如何使用 -moz-element() 创建反射?

jQuery 选择具有特定 CSS 的元素