//兼容性返回相应值 function winwidth() { var winwidth = 0; if (window.innerwidth) winwidth = window.innerwidth; else if ((document.body) && (document.body.clientwidth)) winwidth = document.body.clientwidth; if (document.documentelement && document.documentelement.clientwidth) winwidth = document.documentelement.clientwidth; return winwidth; //返回浏览器height值 } function winheight() { var winheight = 0; if (window.innerheight) winheight = window.innerheight; else if ((document.body) && (document.body.clientheight)) winheight = document.body.clientheight; if (document.documentelement && document.documentelement.clientheight) winheight = document.documentelement.clientheight; return winheight; //返回浏览器height值 } function screenwidth(){ return window.screen.width; } //返回浏览器分辨率width值 var wwidth = 0; var wheight = 0; var swidth = 0; var ratio = 0; var ratio1 = 0; var margintop1 = 0; function websize(){ wwidth = winwidth();//width值 wheight = winheight();//height值 swidth = screenwidth();//分辨率width值 $(".bodyer_content").css({"height":wheight-102,"width":wwidth}); ratio = parseint($(".bodyer_content").width())/parseint($(".bodyer_content").height()); if(ratio > 2.017654477){ $(".image_block img").css({width:$(".bodyer_content").width(),height:"auto"}); }else{ $(".image_block img").css({height:$(".bodyer_content").height(),width:"auto"}); } } $(function(){ websize(); }) $(window).resize(function(){ websize(); });