sticky footer布局,定位底部footer
2017-03-07 22:00
309 查看
其作用就是当内容区域比较少时,让footer也能正常定位到底部,以前我们使用js来达到这种效果,其实用css也是完全可以的
原理我不清楚,效果很完美
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>sticky footer</title> <style type="text/css"> /* 第一步设置盒子为满屏大小 */ .box{ position: fixed; width: 100%; height: 100%; top: 0; left: 0; overflow: auto; background: green; } /* 第二步子盒子设置最小高度且清除浮动 */ .box .main{ width: 100%; min-height: 100%; } .box .main .content{ background: orange; } /* 第三步footer的高度和margin-top要相等 */ .box .footer{ position: relative; width: 100%; height: 100px; background: #f3f3f3; margin: -100px auto 0 auto; clear: both; text-align: center; } .clearfix{ display: inline-block; } .clearfix::after{ content: "."; display: block; height: 0; line-height: 0; visibility: hidden; clear: both; } </style> </head> <body> <div class="box"> <div class="main clearfix"> <div class="content"> <p>这里是内容区域</p> <p>这里是内容区域</p> <p>这里是内容区域</p> </div> </div> <div class="footer">这是footer区域</div> </div> </body> </html>
原理我不清楚,效果很完美
相关文章推荐
- A CSS Sticky Footer——CSS底部固定布局分析
- header+section+footer(底部按钮布局)
- 2.Sticky-footer-flexbox布局方法
- 【css技能提升】完美的 Sticky Footer 布局
- 两种最常用的Sticky footer布局方式
- Sticky Footer 绝对底部的两种套路
- 【转贴】CSS Sticky Footer: 完美的CSS绝对底部
- 详解Sticky Footer 绝对底部的两种套路
- css sticky footer布局
- HTML5:footer定位(底部+居中)的探讨+div图片居中问题
- sticky footer 布局
- Sticky Footer,完美的绝对底部
- CSS Sticky Footer: 完美的CSS绝对底部
- footer定位到页面底部
- html布局让footer始终处在底部
- Sticky Footer 让页脚紧贴页面底部
- 【转载】CSS Sticky Footer: 完美的CSS绝对底部
- 网页布局—StickyFooter
- 如何将页脚固定在页面底部(sticky footer)
- CSS Sticky Footer布局