标签:style blog http color java io ar 2014 div
<script type=‘text/javascript‘> $(function(){ var screenWidth = $(window).width(); var screenHeight = $(window).height(); //console.log(screenWidth+‘//‘+screenHeight); var screenScale = screenWidth/screenHeight; var imgWidth = $(‘.banner6 img‘).width(); var imgHeight = $(‘.banner6 img‘).height(); var scale = imgWidth/imgHeight; if(screenScale > scale){ $(‘.banner6 img‘).width(screenWidth);//以宽为标准 $(‘.banner6 img‘).height(screenWidth/scale); //console.log(‘11:‘+ $(‘.banner6 img‘).width()+‘:‘+$(‘.banner6 img‘).height()); }else{ $(‘.banner6 img‘).width(screenHeight*scale);//以高为标准 $(‘.banner6 img‘).height(screenHeight); //console.log(‘22:‘+ $(‘.banner6 img‘).width()+‘:‘+$(‘.banner6 img‘).height()); } }) </script>
【javascript】javascript实现background-size:cover的功能
标签:style blog http color java io ar 2014 div
原文地址:http://www.cnblogs.com/positive/p/3937616.html