JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div id="header">Header Section</div>
<div id="page" class="clearfix">
<div id="left">Left Sidebar</div>
<div id="content">Main content</div>
<div id="right">Right sidebar</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>123
</div>
<div id="footer">Footer Section</div>
</div>
CSS
html,body {
margin: 0;
padding:0;
height: 100%;
}
#container {
min-height:100%;
height: auto !important;
height: 100%; /*IE6不识别min-height*/
position: relative;
}
#header {
background: #ff0;
padding: 10px;
}
#page {
width: 960px;
margin: 0 auto;
padding-bottom: 60px;/*等于footer的高度*/
}
#footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;/*脚部的高度*/
background: #6cf;
clear:both;
}
/*=======主体内容部分=======*/
#left {
width: 220px;
float: left;
margin-right: 20px;
background: lime;
}
#content {
background: orange;
float: left;
width: 480px;
margin-right: 20px;
}
#right{
background: green;
float: right;
width: 220px;
}
JavaScript
/*Sticky Footer方案*/
/*
将页面的header,主体以及footer都包裹在container中,
页面中的html,body,container都必须满足height:100%,这样就可以占满整个页面
footer使用相对定位,bottom:0,固定在页面底部
页面主题page容易必须要设置一个大于等于footer高度的padding-bottom,目的就为了将footer的高度计算在page容器中
*/
/*
优点:
结构简单清晰,无需js和任何hack能实现各浏览器下的兼容,并且也适应iphone。
缺点:
footer必须要固定高度,page必须要设置一个大于等于这个高度的padding-bottom
*/