css - 当内容很短时强制页脚到浏览器底部的现代技术是什么?

标签 css sticky-footer

我发现很多地方都提到了 Ryan Fait 的技术:http://ryanfait.com/sticky-footer/

还找到了这个:http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page

但它们看起来都过时且老旧,即使代码确实有效。有没有更简单的东西可以在现代浏览器中运行?

最佳答案

这是制作粘性页脚的更简洁的方法,不需要额外的包装器,并且适用于包括 IE8 在内的所有浏览器。

html {
 position: relative;
 min-height: 100%;
}

body {
 margin: 0 0 110px; /* bottom = footer height + margin of the footer */
}

footer {
 position: absolute;
 left: 0;
 bottom: 0;
 margin-top:10px;
 height: 100px;
 width: 100%;
}

关于css - 当内容很短时强制页脚到浏览器底部的现代技术是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16571062/

相关文章:

浏览器调整大小时 CSS 100% 宽度

css - sass 编译错误说 $color : null is not a color even though i declared color

css - float 页脚问题

javascript - 其他 div 内的粘性页脚

mobile - 具有三次贝塞尔过渡的星巴克移动导航

css - 垂直对齐图像旁边的多行文本 - 全部居中

javascript - 链接 Bootstrap 的本地副本

android - 底部的粘性 ScrollView 项目 - Android

CSS:粘性页脚不起作用

html - 内容展开时向下移动的粘性页脚