效果圖如下:
程式碼如下:
複製程式碼
程式碼:
本地圖片預覽
";
}
}
function clacImgZoomParam( maxWidth, maxHeight, width, height ){
var. = {top:0, left:0, width:width, height:height};
if( width>maxWidth || height>maxHeight )
{
rateWidth = width / maxWidth; = height / maxHeight;
if( rateWidth > rateHeight )
{
param.width = maxWidth;
param.height = Math.round(height / rateWidth); else
{
param.width = Math.round(width / rateHeight);
param.height = maxHeight;
}
}
param. round((maxWidth - param.width) / 2);
param.top = Math.round((maxHeight - param.height) / 2);
return param;
}
script>