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 ...
随机推荐
- Android OpenGL ES .介绍
引自:http://blog.csdn.net/hgl868/article/details/6971624 1. OpenGL ES 简介 Android 3D引擎采用的是OpenGL ES. ...
- curl file_get_contents fsockopen
三种处理的方式: curl file_get_contents fsockopen fsockopen 是比较底层的调用,属于网络系统的socket调用,而curl经过的包装支 ...
- android之相机开发
http://blog.csdn.net/jason0539/article/details/10125017 android之相机开发 分类: android 基础知识2013-08-20 22: ...
- 读《Ext.JS.4.First.Look》随笔
Ext JS 4是最大的改革已经取得了Ext框架.这些变化包括一个新类系统,引入一个新的平台,许多API变化和改进,和新组件,如新图表和新画组件.Ext JS 4是更快,更稳定,易于使用.(注意:Ex ...
- Memcached函数整理
public bool Memcached::add ( string $key , mixed $value [, int $expiration ] ) 向key中添加值,如果key存在,返回f ...
- Android Camera Api的心得
(一) 前言最近看Camera的api,觉得写的真的不错.现在翻译过来,给大家分享分享,译文可能不太好,大家将就着看哈. (二) 正文1. CameraCamera是Android framework ...
- linux修改句柄数
linux服务器大并发调优时,往往需要预先调优linux参数,其中修改linux最大文件句柄数是最常修改的参数之一. 在linux中执行ulimit -a 即可查询linux相关的参数,如下所示: [ ...
- UIApplication,UIWindow,UIViewController,UIView(layer)
转载自:http://www.cnblogs.com/iCocos/p/4684749.html UIApplication,UIWindow,UIViewController,UIView(laye ...
- Python3基础 list(enumerate()) 将一个列表的每一个元素转换成 带索引值的元组
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- Combox下拉绑定DataGridView
这个Combox下拉很多人都在用 但其中绘制的语句如下: #endregion #region 方法 #region 绘制DataGridView以及下拉DataGridView private v ...