我有一个脚本正在计算屏幕的宽度 -225px 但是我想在屏幕达到 1100px 时更改它,以便该函数只使用整个宽度。
这是我正在使用的代码:
function slide_holder(){
$('#main').css({'width': (($(window).width()) - 225 )+'px'});
$('.flexslider-container').css({'height': (($(window).height()) - 85 )+'px', 'width': (($(window).width()) - 225 )+'px'});
$('.flexslider').css({'height': (($(window).height()) - 275 )+'px'});
$('#tS3').css({'height': (($(window).height()) - 200 )+'px'});
$('#foot').css({'width': (($(window).width()) - 325 )+'px'});
}
这就是它的名称:
$(document).ready(function() {
slide_holder();
$(window).bind('resize', slide_holder);
});
我曾想过像这样尝试,但我遇到了很大的失败:
$(window).bind("resize", resizeWindow);
function resizeWindow(e){
var newWindowWidth = $(window).width();
// If width width is below 600px, switch to the mobile stylesheet
if(newWindowWidth < 1100){
function slide_holder(){
$('#main').css({'width': (($(window).width()) - 0 )+'px'});
$('.flexslider-container').css({'height': (($(window).height()) - 85 )+'px', 'width': (($(window).width()) - 0 )+'px'});
$('.flexslider').css({'height': (($(window).height()) - 275 )+'px'});
$('#tS3').css({'height': (($(window).height()) - 200 )+'px'});
$('#foot').css({'width': (($(window).width()) - 105 )+'px'});
}
}
// Else if width is above 600px, switch to the large stylesheet
else if(newWindowWidth > 1100){
function slide_holder(){
$('#main').css({'width': (($(window).width()) - 225 )+'px'});
$('.flexslider-container').css({'height': (($(window).height()) - 85 )+'px', 'width': (($(window).width()) - 225 )+'px'});
$('.flexslider').css({'height': (($(window).height()) - 275 )+'px'});
$('#tS3').css({'height': (($(window).height()) - 200 )+'px'});
$('#foot').css({'width': (($(window).width()) - 325 )+'px'});
}
}
}