利用CSS使footer固定在页面底部
1.HTML基本结构
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>layout</title>
</head>
<body>
<divclass="header">
<h1>head of your website.</h1>
</div>
<divclass="wrapper">
<divclass="content">
<h2>Your website content here.</h2>
<scripttype="text/javascript">
for(var i = ; i<;i++){
document.write(i + "<br />");
}
</script>
</div>
<divclass="clear"><!-- 必不可少 --></div>
</div>
<divclass="footer">
<div><h1>
Copyright (c) </h1></div>
</div>
</body>
</html>
2.CSS样式
<styletype="text/css">
*{
margin: ;/* 把默认值都设为0 */
}
html, body
{
height: %;
width:%;
margin:0auto;/* 居中 */
}
.header
{
height:100px;
background-color:Fuchsia;
}
.wrapper
{
min-height: %;/* IE6 hack*/
height: auto!important;/* height优先级 */
height: %;
margin: 0auto-4em;/* 负值必须等于footer的高度 */
}
.content
{
background-color:Silver;
}
.clear/* 清除浮动 */
{
height: 4em; /* clear的height必须和footer的值样高 */
clear:both;
}
.footer
{
height: 4em;
background-color:Aqua;
}
</style>
3.运行
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>test layout</title> <style type="text/css"> *{ margin: 0;/* 把默认值都设为0 */ } html, body { height: 100%; width:85%; margin:0 auto;/* 居中 */ } .header { height:100px; background-color:Fuchsia; } .wrapper { min-height: 100%;/* IE6 hack*/ height: auto !important;/* height优先级 */ height: 100%; margin: 0 auto -4em;/* 负值必须等于footer的高度 */ } .content { background-color:Silver; } .clear /* 清除浮动 */ { height: 4em; /* clear的height必须和footer的值一样高 */ clear:both; } .footer { height: 4em; background-color:Aqua; } </style> </head> <body> <div class="header"> <h1>head of your website.</h1> </div> <div class="wrapper"> <div class="content"> <h2>Your website content here.</h2> <span id="preserve33807f38a7944fcfb0f20ee485333534" class="wlWriterPreserve"><script type="text/javascript"> for(var i = 0; i<100;i++){ document.write(i + "<br />"); } </script></span> </div> <div class="clear"><!-- 必不可少的 --></div> </div> <div class="footer"> <div><h1> Copyright (c) 2012</h1></div> </div> </body> </html>
利用CSS使footer固定在页面底部的更多相关文章
- 让footer固定在页面底部(CSS-Sticky-Footer)
让footer固定在页面底部(CSS-Sticky-Footer) 这是一个让网站footer固定在浏览器(页面内容小于浏览器高度时)/页面底部的技巧.由HTML和CSS实现,没有令人讨厌的h ...
- footer固定在页面底部的实现方法总结
方法一:footer高度固定+绝对定位 HTML代码: <body> <header>头部</header> <main>中间内容</main&g ...
- HTML中footer固定在页面底部的若干种方法
<div class="header"><div class="main"></div></div> <d ...
- HTML 中使 footer 始终处于页面底部
通常在页面中,需要使页脚 footer 部分始终处于底部.当页面高度不够 100% 时, footer 处于页面最底部,当页面内容高于 100% 时,页脚元素可以被撑到最底部. 方法一:绝对定位 &l ...
- 在不适用fixed的前提下,当内容较少时footer固定在页面底部
使用css,参考国外的一个解决方法: http://ryanfait.com/resources/footer-stick-to-bottom-of-page/ How to use the CSS ...
- Footer固定在页面底部(CSS)
<style type="text/css"> #wapper{ position: relative; /*重要!保证footer是相对于wapper位置绝对*/ h ...
- 让footer固定在页面(视口)底部(CSS-Sticky-Footer)
让footer固定在页面(视口)底部(CSS-Sticky-Footer) 这是一个让网站footer固定在浏览器(页面内容小于浏览器高度时)/页面底部的技巧.由HTML和CSS实现,没有令人讨厌的h ...
- 使用css方法使footer保持在页面的最底部
使footer保持在页面的底部,是常见的需求,之前面试的时候也遇见了一个这样的问题,今天在这里记录下css实现的方式. 使footer保持在页面的底部,需要考虑header+content部分不够多的 ...
- 页面元素固定在页面底部的纯css代码(兼容IE6)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- 02_jQuery对象初识(二)筛选器1
0. HTML对象和jQuery对象的区别: 1.jQuery对象转换成DOM对象,用索引取出具体的标签 2.DOM对象转换成jQuery对象,$(DOM对象) 注意:jQuery对象保存到变量的时候 ...
- java连接SQLserver数据库模板代码
package cn.mldn.lxh.dbc; import java.sql.Connection; import java.sql.DriverManager; public class Dat ...
- 次短路poj3463
poj3463大意:统计最小的长度个数+统计最小的长度+1的个数,大概就是求最短路和次短路的条数更新的时候有5种情况,有个细节就是它得是二维的,一个表示节点编号,一个0/1表示它是次短路的还是最短路的 ...
- myeclipse 配置resin
一.新建web project 二.配置本地resin 创建resin/conf/test.conf文件(可从resin.conf copy)中修改 <web-app id="/&qu ...
- Java虚拟机系列(四)---查看GC日志
这一节穿插一点如何在eclipse中配置并查看某个Java应用GC日志的知识点,我也是通过调研知道的,因为书中写的不是很详细,主要是为下一节做准备. 一.eclipse中配置GC 在eclipse中如 ...
- 给NetBeans配置javafx环境
JavaFX开发环境安装配置,这里给大家介绍一个非常有用的步骤 从Java8开始,JDK(Java开发工具包)包括了JavaFX库. 因此,要运行JavaFX应用程序,您只需要在系统中安装Java8或 ...
- Chapter 1 线性表
Preface: 这部分主要是我考研之前的总结,留作以后用到时再翻出来看看.都是基础的知识点,望各(Da)位(Lao)不喜勿喷,欢迎指正. 适用人群:考研复习过一遍数据结构的,可以看看,查漏补缺(顺便 ...
- 使用Maven编译运行Storm入门代码(Storm starter)(转)
Storm 官方提供了入门代码(Storm starter),即 Storm安装教程 中所运行的实例(storm-starter-topologies-0.9.6.jar),该入门代码位于 /usr/ ...
- vue项目中实现扫码功能
项目地址:https://github.com/wkl007/vue-scan-demo.git 项目主要是做的一个扫码的功能 核心代码为 <div class="scan" ...
- TZ_16_Vue_入门案例
1.新建一个html文件导入vue.js <script src="node_modules/vue/dist/vue.js"></script> 2.创建 ...