在网页设计中,Sticky footers设计是最古老和最常见的效果之一,大多数人都曾经经历过。它可以概括如下:如果页面内容不够长的时候,页脚块粘贴在视窗底部;如果内容足够长时,页脚块会被内容向下推送。
html部分:
<!--使用这个布局的前提,就是close关闭按钮要在总的div容器之外,close关闭按钮使用一个层,其它所有内容使用一个总的层。-->
<div class="box-wrapper">
<div class="main">
内容
</div>
</div>
<div class="close">
<i class="icon-close">x</i>
</div>
style部分
html, body {height: 100%;}
.box-wrapper{
min-height :100%/*容器的最小高为100%*/
}
.main{
padding-bottom :64px;/*底部的距离+关闭按钮的大小的总高,这个很重要不能少*/
}
.close{
position: relative;
height :32px;/*关闭按钮的大小,根据实际的项目来*/
width :32px;
margin :-64px auto 0 auto;/*-64px要和padding-bottom 64px相等*/
clear: both;
}