1.JS主代码,界面初始化加载
window.onload = function(){
//解决footer处于顶部问题
var minBg = document.getElementsByClassName("minBg")[0];//minBg为footer上方的div容器
if(minBg != undefined){
var divHeight = document.getElementsByClassName("minBg")[0].offsetHeight;
//footer是底部class
var footerHeight = document.getElementsByClassName("footer")[0].offsetHeight;
var brw = document.documentElement.clientHeight;
if(divHeight <= (brw-footerHeight)){
//加class
setTimeout(addFooterFixed(), 300);
//$(".footer").addClass("footerFixed");
} else {
//去掉class
setTimeout(removeFooterFixed(), 300);
//$(".footer").removeClass("footerFixed");
}
}
};
function addFooterFixed(){
$(".footer").addClass("footerFixed");
}
function removeFooterFixed(){
$(".footer").removeClass("footerFixed");
}
2.css
.footerFixed{
position:fixed;
bottom:0;
width:100%;
}