我遇到的问题是该网站一直在页面底部提供一个很大的空白区域,知道为什么会这样吗?
我在内容上有这个CSS:
#content{
width: 990px;
margin: 0 auto;
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -40px;
position: relative;
}
.full-background {
z-index: -999;
min-height: 100%;
min-width: 1024px;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
}
我正在使用此脚本将背景图像适合窗口:
function fittobox(){
$('.fittobox').each(function(){
$(this).fitToBox();
})
}
$(window).bind({
'load' : fittobox,
'resize' : fittobox
})
用函数更新
// fitToBox
jQuery.fn.fitToBox =
function(){
var div = this.parent();
var img = this;
var imAR = img.attr("height") / img.attr("width");
var bgAR = div.height() / div.width();
if(imAR >= bgAR){
img.attr("width" , div.width());
img.attr("height" , div.width() * imAR);
}else{
img.attr("height" , div.height());
img.attr("width" , div.height() / imAR);
}
div.css({
"position" : "absolute",
"overflow" : "hidden"
});
img.css({
"position" : "absolute",
"left" : (div.width() - img.attr("width"))/2,
"top" : (div.height() - img.attr("height"))/2
});
img.fadeIn();
};
谢谢!