Skip to content

Instantly share code, notes, and snippets.

@janily
Created July 31, 2013 12:27
Show Gist options
  • Select an option

  • Save janily/6121565 to your computer and use it in GitHub Desktop.

Select an option

Save janily/6121565 to your computer and use it in GitHub Desktop.
页脚固定在底部
<div id="container">
<div id="content">页面正文</div>
</div>
<div class="footer">我在底部</div>
html, body{
height:100%;
}
#container {
min-height:100%; /*使内容高度和body一样*/
margin-bottom:-80px;/*向上缩减80像素,不至于footer超出屏幕可视范围*/
}
#content {
padding-bottom:150px; /*这个是关键,处理页面高度超出屏幕可视范围时,控制内容和底部高度之间距离*/
}
#footer {
height:80px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment