【发布时间】:2015-01-30 12:39:52
【问题描述】:
在下面的代码中为什么需要.page-wrap:after?
理论上,如果没有这个,粘性页脚不应该工作吗?为什么没有?
* {
margin: 0;
}
html, body {
height: 100%;
}
.page-wrap {
min-height: 100%;
/* equal to footer height */
margin-bottom: -142px;
}
.page-wrap:after {
content: "";
display: block;
}
.site-footer, .page-wrap:after {
height: 142px;
}
.site-footer {
background: orange;
}
<div class="page-wrap">
Content!
</div>
<footer class="site-footer">
I'm the Sticky Footer.
</footer>
【问题讨论】:
标签: css sticky-footer