css底部不动的布局方法[分享][完美]
2013-07-02 21:39
211 查看
原理是:
1.定义一个绝对高度为100%的容器,包含min-height属性。所有相关作用的代码置于其中。
2.头部默认布局;
3.布局内容容器(中间)内边距为 指定 px(大于等于footer高度)
4.布局footer为绝对定位。
原文:
http://codecamel.com/fullheight
代码如下:
HTML
CSS:
1.定义一个绝对高度为100%的容器,包含min-height属性。所有相关作用的代码置于其中。
2.头部默认布局;
3.布局内容容器(中间)内边距为 指定 px(大于等于footer高度)
4.布局footer为绝对定位。
原文:
http://codecamel.com/fullheight
代码如下:
HTML
<body> <div id="wrapper"> <div id="header">Header added just for demonstration purposes</div> <div id="content">Main content goes here</div> <div id="footer">And this is my footer</div> </div> </body>
CSS:
html, body { margin: 0; padding: 0; height: 100%; } #wrapper { height: auto !important; min-height: 100%; height: 100%; position: relative; /* Required to absolutely position the footer */ } #footer { height: 50px; /* Define height of the footer */ position: absolute; bottom: 0; /* Sit it on the bottom */ left: 0; width: 100%; /* As wide as it's allowed */ } #content { padding-bottom: 50px; /* This should match the height of the footer */ }
相关文章推荐
- CSS布局:让页脚始终保持底部的方法
- 分享用纯CSS实现三列DIV等高布局的方法
- [分享] 纯CSS完美实现垂直水平居中的6种方式
- 关于css布局中左侧固定右侧自适应的几种方法
- 转载:CSS实现三栏布局的四种方法示例
- CSS布局分享
- CSS三栏布局(两边固定中间自适应宽度)的方法
- CSS 布局实例系列(一)总结CSS居中的多种方法
- CSS布局之div交叉排布与底部对齐--flex实现
- Equal Height Columns --DIV+CSS布局中自适应高度的解决方法
- CSS实现绝对底部一个完美解决方案
- 仿微信 QQ聊天布局 顶部title固定,底部是EditText,中间是RecyclerView,弹出软键盘,RecyclerView上移,标题不动
- div+css网页布局分享
- 用CSS的float和clear创建三栏液态布局的方法(好)
- Css三栏布局自适应实现几种方法
- CSS自动竖向排列的布局方法
- 如何防止css高度塌陷最推荐的方法:使用伪元素(这样不会对文档布局造成影响)
- [转] CSS完美兼容IE6/IE7/FF的通用方法
- 个人认为最完美的css处理div圆角的方法
- CSS布局方法(收集)