页面图片显示(按比例缩放)


function scaleImage(ImgD, FitWidth, FitHeight){
var width = ImgD.width, height = ImgD.height;
var w = width / FitWidth, h = height / FitHeight;
if (w >= h) { //宽度固定,高度缩放
ImgD.width = FitWidth;
ImgD.height= height / w;
jQuery(ImgD).css("margin-top", (FitHeight-ImgD.height) / 2); //垂直居中
} else { //高度固定,宽度缩放
ImgD.height= FitHeight;
ImgD.width = width / h;
}
};



页面图片显示(按比例缩放)
文章图片


    推荐阅读