html - 使 css 页脚保持在内容下方

标签 html css

我有这个 CSS:

.lh_container {
    width:960px;
    margin:0 auto 40px auto;
    position:relative;
}

.lh_footer {
    position:absolute;
    bottom:0;
    width:100%;
    height:60px;            /* Height of the footer */
    background:#6cf;
}

.lh_footer-container {
    display:block;
    width:80%;
    margin: 0 auto;
    overflow: hidden;
}

和这个 HTML:

<div class="lh_container">

<div class="lh_footer">
    <div class="lh_footer-container">

    <div class="lh_footer_text">
    &copy; Copyright <?php echo date("Y"); ?>
    </div>

    </div>
</div>

</div><!-- container -->

但页脚不会停留在页面底部 - 我怎样才能做到这一点?

最佳答案

使用 fixed 而不是 absolute

http://jsfiddle.net/pnLyh/

关于html - 使 css 页脚保持在内容下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169538/

相关文章:

css - 如何防止覆盖 div 在底部创建额外空间?

javascript - 如何保持滚动条始终在底部?

html - 空白 :nowrap expands div?

html - Chrome 字体大小加载较大然后减小

html - 导航栏未正确居中 (HTML/CSS)

javascript - 需要我的 jQuery 选项卡在事件且已经打开时不关闭

html - 并排显示单选按钮

html - 链接到页面底部附近的 anchor

javascript - 显示和值取决于具有不同值的下拉菜单的选项

css - 为什么 Chrome DevTools 没有向我显示样式表规则所属的内容?