html 设置页脚div一直在页面底部
先上代码
<!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一直在页面底部的更多相关文章
- DIV+CSS:页脚永远保持在页面底部
页脚永远保持在页面底部 有时候,我们用CSS创建一个高度自适应布局,如何保证页脚(footer)在内容不超过一屏的情况下始终保持在布局最下方是一个比较头疼的事.我看过一些利用绝对定位的例子,但总感觉不 ...
- CSS + DIV 让页脚始终保持在页面底部
来源:David's Blog http://www.DavidQiu.com/ 文章链接:http://blog.davidqiu.com/post/2013-06-17/400517539 ...
- Sticky Footer (让页脚永远停靠在页面底部,而不是根据绝对位置)
<!doctype html><html> <head> <meta charset="UTF-8"> <meta name= ...
- div浮动在页面底部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 【转载自W3CPLUS】如何将页脚固定在页面底部
该文章转载自:W3CPLUS 大漠的文章 http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 以下为全文 作为一个Web的 ...
- 将HTML页面页脚固定在页面底部(多种方法实现)
当一个HTML页面中含有较少的内容时,Web页面的footer部分随着飘上来,处在页面的半腰中间,给视觉效果带来极大的影响,接下来为大家介绍下如何将页脚固定在页面底部,感兴趣的朋友可以了解下 作为一个 ...
- 如何将页脚固定在页面底部,4中方法 转载自:W3CPLUS
原博客地址:http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 作为一个Web的前端攻城师,在制作页面效果时肯定有碰到下面 ...
- C# 操作Word页眉页脚——奇偶页/首页不同、不连续设置页码、复制页眉页脚、锁定页眉页脚、删除页眉页脚
前言 本文是对Word页眉页脚的操作方法的进一步的阐述.在“C# 添加Word页眉页脚.页码”一文中,介绍了添加简单页眉页脚的方法,该文中的方法可满足于大多数的页眉页脚添加要求,但是对于比较复杂一点的 ...
- 005-CSS让页脚始终在底部不论页面内容多少
让页脚始终在页面底部,不论页面内容是多或者少页脚始终在页面底部. 方案一: <!DOCTYPE html> <html> <head> <meta chars ...
随机推荐
- eclipse 终极操作技巧
eclipse作为一个java开发必备软件,从用户体验来说,还是蛮一般的(按照初始设置的话),所以有必要进行一些设置上的改良,加上对一些好用的快捷键的挖掘,能让你用eclipse更加得心应手,事半功倍 ...
- HDU 1072/BFS
题目链接 Nightmare Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDU 3038 How Many Answers Are Wrong (并查集)---并查集看不出来系列-1
Problem Description TT and FF are ... friends. Uh... very very good friends -________-bFF is a bad b ...
- HDOJ--ACMSteps--2.1.8--Leftmost Digit-(取对数,数学)
Problem Description Given a positive integer N, you should output the leftmost digit of N^N. Input T ...
- EDA 事件驱动框架
事件代表过去发生的事件,事件既是技术架构概念,也是业务概念.以事件为驱动的编程模型称为事件驱动架构EDA. EDA是一种以事件为媒介,实现组件或服务之间最大松耦合的方式.传统面向接口编程是以接口为媒介 ...
- 转:Selenium2.0之grid学习总结
(一)介绍: Grid的功能: 并行执行 通过一个中央管理器统一控制用例在不同环境.不同浏览器下运行 灵活添加变动测试机 (二)快速开始 这个例子将介绍如何使用selenium2.0的grid,并且注 ...
- JavaScript(四)---- 函数
函数主要用来封装具体的功能代码. 函数是由这样的方式进行声明的:关键字 function.函数名.一组参数,以及置于括号中的待执行代码. 格式: function 函数名(形参列表){ ...
- 分享一款CSS框架
1.http://bulma.io/documentation/elements 2.支持IE9+ 3.内容:
- mytest 截图
- 零成本实现Android/iOS自动化测试:基于Appium和Test Perfect
https://item.taobao.com/item.htm?spm=a230r.1.14.14.42KJ3L&id=527677900735&ns=1&abbucket= ...