这是我的代码:
#footer {
font-size: 10px;
position:absolute;
bottom:0;
background:#ffffff;
}
我不知道这有什么问题 - 谁能帮忙?
编辑:为了更清楚地说明问题所在:页脚在页面加载时按预期显示在底部。但是,当网页的高度大于屏幕上的尺寸以致出现滚动条时,页脚将保留在同一位置。也就是说,当页面高度 <= 100% 时,页脚在底部。但是,当页面高度 >100% 时,页脚不在该页面的底部,而是在可见屏幕的底部。
编辑:令人惊讶的是,以下解决方案均无效。我最终实现了侧边栏。
最佳答案
您可能正在寻找 this example :
<div class="wrapper">
Your content here
<div class="push"></div>
</div>
<div class="footer">
Your footer here
</div>
CSS:
对于 142 像素的页脚
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
height: 142px; /* .push must be the same height as .footer */
}
/*
Sticky Footer by Ryan Fait
http://ryanfait.com/
*/
关于html - 我怎样才能强制我的页脚贴在 CSS 中任何页面的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5516910/