当前第2页 返回上一页
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | html,body {
margin : 0 ;
padding : 0 ;
height : 100% ;
}
#container {
min-height : 100% ;
height : auto !important ;
height : 100% ;
position : relative ;
}
#header {
background : #ff0 ;
padding : 10px ;
}
#page {
width : 960px ;
margin : 0 auto ;
padding-bottom : 60px ;
}
#footer {
position : absolute ;
bottom : 0 ;
width : 100% ;
height : 60px ;
background : #6cf ;
clear : both ;
}
|
从css代码中,我们看到,页面主体 page 设置了一个 padding-bottom ,并且与 footer 的高度是一致的。这里不能使用 margin-bottom 来代替 padding-bottom 。
这个方案有一个缺点: footer 必须要固定高度, page 必须要设置一个大于等于这个高度的 padding-bottom 。如果 footer 不是固定高度的,或者需要对footer做自适应,那么这种方案就不太适合了。
相关推荐:CSS教程
以上就是css如何让页脚固定在底部的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
css如何设置图层在最上面
纯css如何绘制双箭头(代码示例)
css如何实现表单label的两端对齐(代码示例)
css border-right-color属性怎么用
css内边框如何设置
css如何修改字体大小
css怎么改变光标颜色
纯css实现图片左右翻转效果(附代码)
css如何去除字体的加粗效果
css的工作过程介绍(图文)
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css如何让页脚固定在底部