我有一个网页有几页。每页都有不同的高度(很明显,但我提到它)。只有当页面为“short”时,才将页脚放在底部
我想实现的是,如果页面的内容低于浏览器视口,页脚标签将获得固定的位置并且将与页面底部对齐。
iv'e试过这个js:
$(function(){
if ($(document).height() > $("footer").offset().top+44) {
$("footer").addClass('fixbottom');
}
}
});
$(window).resize(function() {
if ($(document).height() > $("footer").offset().top+44) {
$("footer").addClass('fixbottom');
}
});
和CSS:
.fixbottom {
width: 100%;
position: fixed;
bottom: 0;
}
footer {
height:44px;
background: #7abde9;
color: #ffffff;
text-align: center;
}
在我的jQuery顶部+ 44,因为我的页脚标签44的高度 iv'e使用准备文件并调整窗口大小以确保所有情况都应该符合,但不幸的是,这在任何情况下都不起作用。
任何帮助应该很大appriciated
参见[这](http://ryanfait.com/resources/footer- ) – Peter