让footer在底部(测试它人方法)
要求:网页布局中,页脚在底部.内容不够一页时,在底部.内容超过一页时,出现卷动条,页脚也在被挤到底部
1.测试的这个文章介绍的办法 链接: http://www.cnblogs.com/chenyuming507950417/p/4003651.html
经测试,这个办法可以实现要求.
2.测试代码说明
html结构:
<div class="container">
<div class="header">头</div>
<div id="content" class="content">内容</div>
<div class="footerbox">脚部</div>
</div>
css(关键)
.container {
position: absolute; /*关键1,容器定位是 absolute,测试发现换成 relative 的,会不行.*/
min-height: 100%; /*关键2,容器的最小高度为视口高度*/
/**/
width: 100%;
}
.content {
/*这个距离是内容区到footer的距离,防止footer遮住内容区域*/
padding-bottom: 54px;
}
.footerbox {
position: absolute; /*关键3,绝对定位,相对于.container*/
bottom: 0px; /*关键4,定位位置在底部*/
/**/
background-color: #000;
height: 30px;
line-height: 30px;
margin: 0;
padding: 0;
width: 100%;
}
3.完整测试代码
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>CSS + DIV 让页脚始终底部</title>
<meta name="generator" content="" />
<style type="text/css">
* {
margin: 0;
padding: 0;
} .container {
position: absolute; /*关键1,容器定位是 absolute,测试发现换成 relative 的,会不行.*/
min-height: 100%; /*关键2,容器的最小高度为视口高度*/
/**/
width: 100%;
} .content {
/*这个距离是内容区到footer的距离,防止footer遮住内容区域*/
padding-bottom: 54px;
} .footerbox {
position: absolute; /*关键3,绝对定位,相对于.container*/
bottom: 0px; /*关键4,定位位置在底部*/
/**/
background-color: #000;
height: 30px;
line-height: 30px;
margin: 0;
padding: 0;
width: 100%;
} .footer {
width: 1080px;
color: forestgreen;
height: 30px;
line-height: 30px;
margin: 0 auto;
} p {
text-align: center;
font-size: 1em;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
底部footer,内容少时自动在最底下,内容多时撑开后到最底下
<button onclick="additem()">增加内容</button>
</div>
<div id="content" class="content"> </div>
<div class="footerbox">
<div class="footer">
这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚,这是脚
</div>
</div>
</div>
<script>
for (var i = 0; i < 35; i++) {
var about = document.getElementById("content");
var para = document.createElement("p");
var node = document.createTextNode("这是原有内容" + about.childElementCount);
para.appendChild(node);
about.appendChild(para);
}
function additem() {
var about = document.getElementById("content");
var para = document.createElement("p");
var node = document.createTextNode("新加入一行内容" + about.childElementCount);
para.appendChild(node);
about.appendChild(para)
}
</script>
</body>
</html>
让footer在底部(测试它人方法)的更多相关文章
- HTML中footer固定在页面底部的若干种方法
<div class="header"><div class="main"></div></div> <d ...
- 如何将页脚固定在页面底部,4中方法 转载自:W3CPLUS
原博客地址:http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 作为一个Web的前端攻城师,在制作页面效果时肯定有碰到下面 ...
- 网页布局中页面内容不足一屏时页脚footer固定底部
方法一:给html.body都设置100%的高度,确定body下内容设置min-height有效,然后设置主体部分min-height为100%,此时若没有header.footer则刚好完美占满全屏 ...
- CSS实现Footer固定底部,超过一屏自动撑开
方法一:给html.body都设置100%的高度,确定body下内容设置min-height有效,然后设置主体部分min-height为100%,此时若没有header.footer则刚好完美占满全屏 ...
- Apache ab测试工具使用方法(无参、get传参、post传参)(转)
转自Apache ab测试工具使用方法(无参.get传参.post传参) Ab测试工具是apache自带的测试工具,具有简单易上手的特性,下面我总结一下我的使用方法,首先去官方下载apache程序包, ...
- LoadRunner测试50人同时登陆下单
LoadRunner测试50人同时登陆下单 一.LoadRunner简介 LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找 ...
- XCode中的单元测试:编写测试类和方法(内容意译自苹果官方文档)
当你在工程中通过测试导航栏添加了一个测试target之后, xcode会在测试导航栏中显示该target所属的测试类和方法. 这一章演示了怎么创建测试类,以及如何编写测试方法. 测试targets, ...
- android 让一个控件按钮居于底部的几种方法
android 让一个控件按钮居于底部的几种方法1.采用linearlayout布局:android:layout_height="0dp" <!-- 这里不能设置fill_ ...
- Randoop测试类和方法(用例自动生成)
详细使用方法见randoop官网: https://randoop.github.io/randoop/manual/index.html 测试程序之前,先检测下你的Randoop是否配置好: 打开c ...
随机推荐
- 引入css外部样式表
前言 为什么会有这篇文章,外部引入样式有什么好谈的,不外乎就是 <link rel="stylesheet" href="style.css" /> ...
- android ioctl fuzz,android 本地提权漏洞 android root
目前正在研究android 三方设备驱动 fuzzer , 也就是下图所说的 ioctl fuzzing, 下图是由keen team nforest 大神发布: 欢迎正在研究此方面的人联系我共同交流 ...
- 错误日志类C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- CentOS下安装JDK6u21和设置环境变量bin文件
1.先通过SSH登录到Linux系统中,通过SSH文件管理工具把Linux的JDK安装包上传到/home/acm/JavaTools/JDK目录: 2.进入/home/acm/JavaTools/JD ...
- $rootScope
参考地址 https://docs.angularjs.org/api/ng/type/$rootScope.Scope angular 的scope一般上都是有继承关系的,也就是说可以通过原型访问到 ...
- bzoj 1197
http://www.lydsy.com/JudgeOnline/problem.php?id=1197 我们考虑从低维向高维考虑. 记F[i][j]表示维度为i,用了j个球时最多能将空间划分为多少个 ...
- Android数据库信息显示在listview上
Key Points: 1.使用SimpleCursorAdapter将Android数据库信息显示在listview上 adapter = new SimpleCursorAdapter(this, ...
- 在CentOS/RHEL 6.5上安装Chromium 谷歌浏览器
之前Google就说了,由于CentOS/RHEL 6已经是过期的系统,所以不再会有Chrome了. 虽然后来由于引起了社区的抗议,从而改口,不再提CentOS/RHEL 6是过期系统了:但是,目前在 ...
- Struts分页
1.分页的bean类PaginationSupport.java 2.写好后直接在action里面调用,计算当前页显示的数据 3.写一个公用的jsp页面,直接在需要分页的页面include就可以了 ...
- Javascript&Jquery获取浏览器和屏幕各种高度宽度方法总结及运用
<js篇> Javascript获取浏览器和屏幕各种高度宽度方法总结 document.body.clientWidth //网页可见区域宽(body) document.bo ...