图片等比例缩放
- JavaScript
- 2013-02-23
- 67热度
- 0评论
页面代码:
[html]
<div id="pic">
<img src="/dd/gg.gif" height="233"/>
</div>
[/html]
js代码
[js]
$(function(){
$("#pic img").each(function() {
var image = $(this);
if (image.width() > 435) {
image.width(435);
image.height(435 / image.width() * image.height());
}
});
});
[/js]