memo

memo dayo.

jQueryで画像の縦横比率を保ったままリサイズする

jQuery.event.add(window, "load", function(){
var cst_w = 320;//fixed width
var cst_h = 320;//fixed height
$('img').each(function(){
var int_w = $(this).width();
var int_h = $(this).height();
if (int_w >= int_h) {
$(this).width(cst_w);
$(this).height(cst_w * int_h / int_w);
} else {
$(this).width(cst_h * int_w / int_h);
$(this).height(cst_h);
}
});
});