利用CSS使footer固定在页面底部的实例代码
2016-05-13 09:15
771 查看
1. HTML基本结构
2. CSS样式
以上这篇利用CSS使footer固定在页面底部的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
<!DOCTYPEhtml> <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> <headrunatheadrunat="server"> <title>layout</title> </head> <body> <divclassdivclass="header"> <h1>head of your website.</h1> </div> <divclassdivclass="wrapper"> <divclassdivclass="content"> <h2>Your website content here.</h2> <scripttypescripttype="text/javascript"> for(var i = 0; i<100;i++){ document.write(i + "<br />"); } </script> </div> <divclassdivclass="clear"><!-- 必不可少 --></div> </div> <divclassdivclass="footer"> <div><h1> Copyright (c) 2012</h1></div> </div> </body> </html>
2. CSS样式
<styletype="text/css"> *{ margin: 0;/* 把默认值都设为0 */ } html, body { height: 100%; width:85%; margin:0auto;/* 居中 */ } .header { height:100px; background-color:Fuchsia; } .wrapper { min-height: 100%;/* IE6 hack*/ height: auto!important;/* height优先级 */ height: 100%; margin: 0auto-4em;/* 负值必须等于footer的高度 */ } .content { background-color:Silver; } .clear/* 清除浮动 */ { height: 4em; /* clear的height必须和footer的值样高 */ clear:both; } .footer { height: 4em; background-color:Aqua; } </style>
以上这篇利用CSS使footer固定在页面底部的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章推荐
- Web布局连载——两栏固定布局(五)
- [div+css]晒晒最新制作专题推广页模板
- 盒子模型
- CSS选择器
- CSS样式优先权
- [css] line-height 百分比单位和数值单位的区别
- Apple官网研究之使用Justify布局导航
- 关于前端的思考与感悟
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表
- 10条影响CSS渲染速度的写法与使用建议第1/3页
- BS项目中的CSS架构_仅加载自己需要的CSS
- 很不错的 CSS Hack 又学了一招
- 发一个css比较清爽的写法
- CSS expression控制图片自动缩放效果代码[兼容 IE,Firefox]
- css布局网页水平居中常用方法
- CSS经典技巧十则第1/2页
- css 兼容性问题this.style.cursor=''hand''
- IE6不能正常解析CSS文件问题的解决方法及原因分析