让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 ...
随机推荐
- HTML&CSS基础学习笔记1.22-简单的注册页面
一个简单的注册页面 表单提交是前后端数据交互的一种方式. 代码区是一个注册页面,其中包含了以下标签:<form>.<table>.<input>.<butto ...
- Spring ioc 原理
java程序员都知道:java程序中的每个业务逻辑至少需要两个或以上的对象来协作完成,通常,每个对象在使用他的合作对象时,自己均要使用像new object() 这样的语法来完成合作对象的申请工作.你 ...
- NGINX配置小随笔
达到以下效果: 1,特定目录被指定IP访问 2,不是指定的IP地址不能执行URI中特定字符串 3,特定目录中不能执行PHP文件 set $self_visit ''; if ( $request_ur ...
- python的工作记录B
这次很强了.就差最后一步,判断一下SVN的版本是否是真的库里的. #!/usr/bin/env python # -*- coding: utf-8 -*- import os,sys,command ...
- 基于Redis的消息订阅/发布
在工业生产设计中,我们往往需要实现一个基于消息订阅的模式,用来对非定时的的消息进行监听订阅. 这种设计模式在 总线设计模式中得到体现.微软以前的WCF中实现了服务总线 ServiceBus的设计模式. ...
- libeXosip2(3-1) -- eXosip2 INVITE and Call Management
eXosip2 INVITE and Call Management SIP messages and call control API Functions int eXosip_call_set_ ...
- zoj2562:搜索+数论(反素数)
题目大意:求n以内因子数量最多的数 n的范围为1e16 其实相当于求n以内最大的反素数... 由素数中的 算数基本原理 设d(a)为a的正因子的个数,则 d(n)=(a1+1)(a2+1)..... ...
- SDN,NFV
CAPEX,capital expenditures 投资成本OPEX,Operating Expense 运营费用space & power consumption 图解NFV与SDN关系
- Android之Intent
前言:大家都知道Android程序的实现一般都由四大组件构成: Activity :Android程序实现功能的主体,提供了和客户交互的界面,也提供了和后台交互的功能. Service :是一个没有界 ...
- startActivity与startActivityForResult的使用小结
1.在一个Activity中想要启动进入另一个Activity时,通常我们使用startActivity这个方法来实现,代码如下: 其中MainActivity为源activity,ActivityL ...