css footer not displaying at the bottom of the page
https://stackoverflow.com/questions/15960290/css-footer-not-displaying-at-the-bottom-of-the-page
There's really two main options:
- Fixed Footer - the footer always is visible at the bottom of the page
- Pushed Footer - the footer is pushed to the bottom of the page even when the content doesn't fill the window
The easier of the two is the fixed footer.
Fixed Footer
To make the footer fixed, in CSS set the footer's position to fixed position:fixed and position the footer to the bottom of the page bottom:0px. Here's a code snippet from CSS-Tricks.
#footer {
position:fixed;
left:0px;
bottom:0px;
height:30px;
width:100%;
background:#999;
}
/* IE 6 */
* html #footer {
position:absolute;
top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}
Pushed Footer
A pushed footer is a bit trickier. Here's a great graphic showing why the footer doesn't stay at the bottom of the page when there isn't enough content:

Basically, the problem is happening because the footer element is 'pushed' under the element that is above it and the height of that element isn't as long as the height of the page. In order to fix this, you need to make sure that the footer gets 'pushed' down the full height of the page (minus the height of your footer).
Here's how to do it:
HTML
<div id="container">
<div id="header"></div>
<div id="body"></div>
<div id="footer"></div>
</div>
CSS
html, body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
background:#ff0;
padding:10px;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
}
Here's a more detailed tutorial on how to do it as well as the source of the code above.
And here's a working demo of the code from the same source.
https://zhuanlan.zhihu.com/p/22936824?refer=nangit
http://blog.csdn.net/m0_38099607/article/details/71598423
这篇文章中的flex可以尝试一下。
需要解决的问题:测试的时候,这两种情况都要测试到
1.在页面内容不够的时候,footer的高度会变高。
2.在页面内容足够的时候,footer会覆盖掉content。
css footer not displaying at the bottom of the page的更多相关文章
- 每天CSS学习之top/left/right/bottom
top:值域是数值或百分比,正负都可以.该值表示 距离顶部有多少像素.例如top:10px:即距离顶部10个像素. left/right/bottom与top如出一辙,只是方向不一样而已. 这些属性一 ...
- css @语法,@规则 @import @charset @font-face @fontdef @media @page
CSS At-Rules Reference 样式表规则 At-Rules 样式表规则 CSS Version 版本 Compatibility 兼容性 Description 简介 @impo ...
- 实用的60个CSS代码片段
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
- 60个有用CSS代码片段
1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...
- 关于前端CSS预处理器Sass的小知识!
前面的话 "CSS预处理器"(css preprocessor)的基本思想是,用一种专门的编程语言,进行网页样式设计,然后再编译成正常的CSS文件.SASS是一种CSS的开发工 ...
- 懒加载实现的分页&&网站footer自适应
最近在做手机端,发现下拉刷新和上拉加载的jq控件很少而且自我感觉不好用,比如iscroll之类-- 然后自己写了个懒加载的,也很简单,最基础的代码[不喜勿喷,但蛮实用的] wap手机端懒加载分页: 用 ...
- 30+有用的CSS代码片段
在一篇文章中收集所有的CSS代码片段几乎是不可能的事情,但是我们这里列出了一些相对于其他的更有用的代码片段,不要被这些代码的长度所吓到,因为它们都很容易实现,并且具有良好的文档.除了那些解决常见的恼人 ...
- CSS易混淆知识点总结与分享-定位与布局
CSS定位有四种模式:static.relative.absolute.fixed,其它static是默认值,下面分别讲解下各自的特点: static:静态定位,处于动态布局流中,按照页面中的各元素先 ...
- 如何提升我的HTML&CSS技术,编写有结构的代码
前言 之前写了四篇HTML和CSS的知识点,也相当于是一个知识点汇总.有需要的可以收藏,平时开发过程中应该会遇到这些点,到时候再查看这些博客可能更容易理解.从这篇开始更多的介绍开发过程经常让人头痛的前 ...
随机推荐
- BZOJ 5104 Fib数列(二次剩余+BSGS)
斐波那契数列的通项: \[\frac{1}{\sqrt{5}}((\frac{1+\sqrt{5}}{2})-(\frac{1-\sqrt{5}}{2}))\] 设T=\(\sqrt{5}*N\),\ ...
- crontab执行脚本和手动执行脚本输出结果不一致的问题处理
背景:huskiesir最近用公司给分配的账户写了脚本去检测某应用状态并发送到企业邮箱,写完脚本之后去执行了一下,发现效果还不错,在邮箱显示效果如下: 10.11.116.6 检查结果OK,检查时间 ...
- 脚本2,从1到99 ,添加用户user1,user2,。。。 user99
脚本2,从1到99 ,添加用户user1,user2,... user99 如果用户user$存在,脚本显示用户存在,否则添加用户,并显示添加用户成功. 脚本如下 [root@localhost ho ...
- python学习--导入自己的包
定义一个自己的方法包: def myFunc(x): if x > 10: return x else: return -x 在需要的地方导入包: # 导入自定义的方法包 from learn ...
- [MST] Create an Entry Form to Add Models to the State Tree
It is time to add new entries to the wishlist. We will achieve this by reusing forms and models we'v ...
- Cocos2dx学习报告2
记录二:创建项目,其名曰DFJ(仿照微信打飞机) 上一个记录我们说到开发环境的配置以及如何去建立自己的项目. 如今我们就通过之前说所的方法来建立一个项目.这里我就不再截图了. 建立了自己的项目之后,我 ...
- hibernate ID生成策略配置
1.Student.hbm.xml配置 <hibernate-mapping package="com.wxh.hibernate.model"> <class ...
- Win 10最大的亮点不是免费而是人工智能
7月27日,日本知名作家Manish Singh发表文章.题为"Eight Reasons Why You Should Upgrade to Windows 10",文中例举下面 ...
- 动态语言切换(续)-designer中的retranslateUi(带源码)
本站所有文章由本站和原作者保留一切权力,仅在保留本版权信息.原文链接.原文作者的情况下允许转载,转载请勿删改原文内容, 并不得用于商业用途. 谢谢合作.原文链接:动态语言切换(续)-designer中 ...
- nj07---npm
一.如何使用包管理器 Node.js包管理器,即npm是Node.js官方提供的包管理工具,它已经成了Node.js包的标准发布平台,用于Node.js包的发布.传播.依赖控制.(可以下载上面的包也可 ...