小编典典

如何使页脚停留在网页的底部?

html

我有一个简单的2列布局,带有页脚,可清除标记中的右和左div。我的问题是我无法在所有浏览器中都将页脚停留在页面底部。如果内容将页脚放下,它会起作用,但并非总是如此。


阅读 525

收藏
2020-05-10

共1个答案

小编典典

要获得页脚的粘性:

  1. 有一个<div>class="wrapper"您的内容。

  2. 收盘</div>的的wrapper地方 <div class="push"></div>

  3. 收盘</div>的的wrapper地方 <div class="footer"></div>

* {
    margin: 0;
}
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 */
}
2020-05-10