/* body的height必须要有 */
body { height: 100%; padding: 0; margin: 0; }
.outer { height: 100%; position: relative; }
.A { height: 100px; background: #BBE8F2; }
/* 注意B没有高度 */
.B { background: #D9C666; width: 100%; position: absolute; top: 100px ; left: 0 ; bottom: 0; }

本文介绍了一种使用CSS实现的固定头部和底部布局的方法。通过设置body的高度为100%,利用绝对定位来固定顶部和底部元素的位置,实现了简洁且响应式的页面布局。
475

被折叠的 条评论
为什么被折叠?



