先上代码

<!DOCTYPE HTML>
<html lang="en" style="height: 100%; width: 100%;">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="page-header-fixed page-sidebar-closed-hide-logo page-sidebar-closed-hide-logo" style="position: absolute; width: 100%; min-height: 100%; height: auto;">
<div class="page-header navbar navbar-fixed-top">
//这部分的div的 position 是 fixed </div>
<div style="position: absolute; min-height: 100%; height: auto; width: 100%; text-align: center;">
<div class="page-container" style="position: relative; margin-bottom: 30px;"></div>
<div class="page-footer" style="position: absolute; bottom: 0px; display: block; width: 100%;"></div>
</div>
</body>
</html>

解析:

1、先设置<html>的 height 为 100%;

2、设置 body 的position 为 absolute,因为它里面的 div 有一个为 fixed,这样可以使得 body 的范围可以包括该div,如果设置为 relatve,则不包括该div。再设置 min-height 为 100%,使其最小高度也为 html 的 height;

3、让内容 div 和页脚 div 都包含在同一个外部 div 中,这样页脚在窗口缩小时不会上浮到内容 div 的位置。

4、外部 div 的 position 设置为 absolute,是由于 body 也为 absolute 的缘故,并设置其 min-height 为 100%,这样可以使其高度最小为 body 的高度,height 为 auto,则使其可以任意改变。

5、页脚 div 的 position 设置为 absolute,bottom 为 0,是为了绝对定位,让其居于页面底部。

最新文章

  1. Javascript初学篇章_8(事件)
  2. [转]mac 10.9.4下配置apache
  3. python 写入csv文件
  4. Java 设计模式学习总结(下)
  5. python学习笔记17(动态类型)
  6. html-----018----HTML Web Server/HTML URL 字符编码
  7. Python Challenge
  8. Android的selector 背景选择器
  9. 查看 NDK 版本
  10. PHP——laravel之DB类-&gt;查询
  11. Python02(Linux命令)
  12. Codeforces Round #555 (Div. 3)[1157]题解
  13. idea中配置Springboot热部署
  14. python多线程学习一
  15. leetcode647
  16. MVC身份验证及权限管理(转载)
  17. 解决Ubuntu17.04以上系统,yarn init报错
  18. jmeter常用组件
  19. JavaScript重点知识(一)
  20. android studio 3.0 集成ijkplayer

热门文章

  1. cURL: Learning..
  2. SSH整合环境下Spring配置文件的配置
  3. Swift 学习笔记 (二)
  4. 在WIN7/8下把XP装入VHD (上)
  5. HDU 5768 Lucky7 (容斥原理 + 中国剩余定理 + 状态压缩 + 带膜乘法)
  6. Linux一些命令
  7. Swift学习(1)
  8. HDU 3696 Farm Game
  9. ubuntu中文论坛
  10. hdu_1007_Quoit Design(最近点对)