基于jquery实现等比缩放图片

基于jquery的图片尺寸调整

resize.js

代码如下:
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width",maxWidth);
$(this).css("height",height ratio);
height = height
ratio;
}
var width = $(this).width();
var height = $(this).height();
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height",maxHeight);
$(this).css("width",width ratio);
width = width
ratio;
}
});
//$("#contentpage img").show();
// IMAGE RESIZE
});

代码很简洁,使用起来也很简单,小伙伴们直接使用即可

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...