作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的 2 列布局,带有一个页脚,可以清除标记中的左右 div。我的问题是我无法让页脚在所有浏览器中都位于页面底部。如果内容将页脚向下推,它会起作用,但情况并非总是如此。
最佳答案
要获得粘性页脚:
有一个 <div>
与 class="wrapper"
为您的内容。
收盘之前 </div>
的 wrapper
放置 <div class="push"></div>
.
收盘后之后 </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 */
}
<div class="wrapper">wrapper
<div class="push">push</div>
</div>
<div class="footer">footer</div>
关于css - 如何让页脚停留在网页底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50614489/
我是一名优秀的程序员,十分优秀!