StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css
来源:动视网
责编:小采
时间:2020-11-27 16:13:14
StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css
StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css_WEB-ITnose: super胡 * { 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
导读StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css_WEB-ITnose: super胡 * { 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

super胡 sagsdhgdf
你会发现,页脚的高度在这里被重复使用了三次,这是至关重要的,而且三个高度必须使用同样的值。wrap 的height属性把自己拉伸至窗口全部高度的尺寸,负的margin会把footer提高到main 的padding的位置上去,因为main已经在wrap的里面,所以main的padding已经是wrap 100%高度的一部分。 这样,footer就留在页面的底部了。
现在还不算完成,我们还需要去clearfix main 。
.clearfix:after {content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;}
.clearfix {display: inline-block;}
/* Hides from IE-mac \*/
* html .clearfix { height: 1%;}
StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css
StickyFooter(让页脚永远停靠在页面底部,而不是根据绝对位置)_html/css_WEB-ITnose: super胡 * { 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