https://stackoverflow.com/questions/15960290/css-footer-not-displaying-at-the-bottom-of-the-page

There's really two main options:

  1. Fixed Footer - the footer always is visible at the bottom of the page
  2. 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。

最新文章

  1. ie11浏览器和chrome浏览器对于bgsound和background的一些区别
  2. [转载]50个Demo展示HTML5无穷的魅力
  3. CK方程
  4. 微服务、SOA 和 API:是敌是友?
  5. 重写session
  6. OCR识别流程
  7. poj 3229 The Best Travel Design ( 图论+状态压缩 )
  8. Jquery JSOPN在WebApi中的问题
  9. C++----练习--整型赋值时的溢出
  10. 用于主题检测的临时日志(18506589-369d-4505-a204-3678db17eae5 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)
  11. node源码详解(三)—— js代码在node中的位置,process、require、module、exports的由来
  12. IIS7.0发布后关于&quot;不能在此路径中使用此配置节”的解决办法
  13. centos6.5安装rabbitmq3.6.14
  14. Solr(三)向solr-5.5.4中添加数据
  15. 设置SecureCRT的背景色和文字颜色方案
  16. 爬虫(三)之scrapy核心组件
  17. 【分布式session】Spring-session的使用
  18. bzoj2555 substring(LCT 后缀自动机)
  19. dedecms 后台修改系统设置,但是config.cache.inc.php文件不能写入
  20. chrome浏览器开发者工具使用教程[转]

热门文章

  1. How Javascript works (Javascript工作原理) (八) WebAssembly 对比 JavaScript 及其使用场景
  2. LightOJ-1220 Mysterious Bacteria 唯一分解定理 带条件的最大公因数
  3. 【Paper Reading】Bayesian Face Sketch Synthesis
  4. 使用Jmeter工具对http接口进行压力测试
  5. man 7 glob
  6. Rancher介绍安装以及对docker的管理
  7. 洛谷—— P2904 [USACO08MAR]跨河River Crossing
  8. JavaScript编写Web脚本最佳实现
  9. windows 下面的grep awk 命令
  10. 程序员之---C语言细节12(指针和数组细节,&amp;quot;//&amp;quot;的可移植性说明)