先上代码

<!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,是为了绝对定位,让其居于页面底部。

html 设置页脚div一直在页面底部的更多相关文章

  1. DIV+CSS:页脚永远保持在页面底部

    页脚永远保持在页面底部 有时候,我们用CSS创建一个高度自适应布局,如何保证页脚(footer)在内容不超过一屏的情况下始终保持在布局最下方是一个比较头疼的事.我看过一些利用绝对定位的例子,但总感觉不 ...

  2. CSS + DIV 让页脚始终保持在页面底部

    来源:David's Blog     http://www.DavidQiu.com/ 文章链接:http://blog.davidqiu.com/post/2013-06-17/400517539 ...

  3. Sticky Footer (让页脚永远停靠在页面底部,而不是根据绝对位置)

    <!doctype html><html> <head> <meta charset="UTF-8"> <meta name= ...

  4. div浮动在页面底部

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. 【转载自W3CPLUS】如何将页脚固定在页面底部

    该文章转载自:W3CPLUS 大漠的文章 http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 以下为全文 作为一个Web的 ...

  6. 将HTML页面页脚固定在页面底部(多种方法实现)

    当一个HTML页面中含有较少的内容时,Web页面的footer部分随着飘上来,处在页面的半腰中间,给视觉效果带来极大的影响,接下来为大家介绍下如何将页脚固定在页面底部,感兴趣的朋友可以了解下 作为一个 ...

  7. 如何将页脚固定在页面底部,4中方法 转载自:W3CPLUS

    原博客地址:http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 作为一个Web的前端攻城师,在制作页面效果时肯定有碰到下面 ...

  8. C# 操作Word页眉页脚——奇偶页/首页不同、不连续设置页码、复制页眉页脚、锁定页眉页脚、删除页眉页脚

    前言 本文是对Word页眉页脚的操作方法的进一步的阐述.在“C# 添加Word页眉页脚.页码”一文中,介绍了添加简单页眉页脚的方法,该文中的方法可满足于大多数的页眉页脚添加要求,但是对于比较复杂一点的 ...

  9. 005-CSS让页脚始终在底部不论页面内容多少

    让页脚始终在页面底部,不论页面内容是多或者少页脚始终在页面底部. 方案一: <!DOCTYPE html> <html> <head> <meta chars ...

随机推荐

  1. Java的引用c++的引用和C指针的区别

    Java的引用本质上就是C中的指针,而c++的引用则完全不同:有一个类 class Point { int x; int y;} 同样的一个Point p; 在Java中p表示一个引用,它等同于C语言 ...

  2. Android中自定义veiw使用Java中的回调方法

    //------------------MainActivity----中---------------------------------- import android.os.Bundle;imp ...

  3. Dom++完美版得到元素到html的距离6/4/21

    function getTop(obj) { var pos={left:0,top:0}; while(obj) { pos.left+=obj.offsetLeft; pos.top+=obj.o ...

  4. byte 读写文件

    import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import ja ...

  5. USACO Section 1.3 Ski Course Design 解题报告

    题目 题目描述 有N座山,每座山都有一个高度,现在由于农夫想避税,所以想把这些山的高度进行一些改变,使得最高的山与最低的山之间的高度差不超过17.每座山最多只能改变一次高度,每次改变高度都会产生一定的 ...

  6. 转:sqlplus与shell互相传值的几种情况

    sqlplus与shell互相传值的几种情况 情况一:在shell中最简单的调用sqlplus $cat test.sh #!/bin/sh sqlplus oracle/oracle@oracle& ...

  7. Hibernate的generator属性

    本文讲述Hibernate的generator属性的意义.Generator属性有7种class,本文简略描述了这7种class的意义和用法. <class name="onlyfun ...

  8. hide the navigationBar and tabBar

    [self.navigationController setNavigationBarHidden:YES animated:NO]; hidesBottomBarWhenPushed

  9. vmware中网络连接方式介绍

  10. HDU 2444 The Accomodation of Students(二分图判定+最大匹配)

    这是一个基础的二分图,题意比较好理解,给出n个人,其中有m对互不了解的人,先让我们判断能不能把这n对分成两部分,这就用到的二分图的判断方法了,二分图是没有由奇数条边构成环的图,这里用bfs染色法就可以 ...