关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

jquery 保证图片永久不变形的小狗狗

发布时间:2019-10-25 16:14:31
function theNewImg_onload(){
    $bgimg.data("newImageW",this.width).data("newImageH",this.height);
    BackgroundLoad($bgimg,this.width,this.height,this.src);
}
//Image scale function
function FullScreenBackground(theItem,imageWidth,imageHeight){
    var showwidth=$("#layout").width();//获得显示区域的宽度
    var showheight=$("#layout").height();//获得显示区域的高度
    //计算出缩小或者放大的比例
    var bili=showwidth/imageWidth;
    var winWidth=$(window).width(); //获得浏览器高和宽
    //alert("当前分辨率宽"+winWidth);
    var winHeight=$(window).height();
    $(theItem).attr("width",showwidth);
    $(theItem).attr("height",imageHeight*bili);
    //alert("显示区域高"+showheight+" ,显示区域宽"+showwidth+",图片缩小或者放大了"+bili+" ,原图片高"+imageHeight+",宽"+imageWidth+",缩小或放大后图片高"+imageHeight*bili+",宽"+showwidth+"。请用计算器算出适合图片大小,实际上,只要根据显示区域比例来做图片。绝对保证图片永久不变形。");
}



/template/Home/Zkeys/PC/Static