这显然是指向粘性页脚的“最佳”解决方案的链接(仅当页面上的内容很少时才会停靠)。
http://ryanfait.com/sticky-footer/
当您在任何其他浏览器(Firefox,我测试过的 chrome)中调整窗口大小时,页脚会随窗口移动。在 IE7 中它不会移动,您需要刷新页面才能使其正确定位。
谷歌似乎能够做到这一点,所以我想知道,他们是如何做到这一点的,而我却做不到?他们是在使用 JavaScript,还是我缺少一个优雅的 CSS 解决方案?
这显然是指向粘性页脚的“最佳”解决方案的链接(仅当页面上的内容很少时才会停靠)。
http://ryanfait.com/sticky-footer/
当您在任何其他浏览器(Firefox,我测试过的 chrome)中调整窗口大小时,页脚会随窗口移动。在 IE7 中它不会移动,您需要刷新页面才能使其正确定位。
谷歌似乎能够做到这一点,所以我想知道,他们是如何做到这一点的,而我却做不到?他们是在使用 JavaScript,还是我缺少一个优雅的 CSS 解决方案?
我以前使用过 Chris Coryier 的解决方案,并且从未遇到过 IE 的任何问题:http: //css-tricks.com/snippets/css/sticky-footer/
CSS
* { margin:0; padding:0; }
html, body, #wrap { height: 100%; }
body > #wrap {height: auto; min-height: 100%;}
#main { padding-bottom: 150px; } /* must be same height as the footer */
#footer {
position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
clear:both;
}
/* CLEAR FIX*/
.clearfix:after {content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {display: inline-block;}
/* Hides from IE-mac \*/
* html .clearfix { height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */
HTML
<div id="wrap">
<div id="main" class="clearfix">
</div>
</div>
<div id="footer">
</div>
这是我使用的一个,它一直对我有用。