开发者

Is it possible with jQuery to dynamically resize an image based on the width of it's parent DIV?

I have a DIV tag that will be 500px in width. Content is coming via an RSS feed that includes images. Some of these images are wider then 500px which destroys the layout. Is it possible to use a bit of jQuery to resize images on the fly if they exceed 500px in width and keep the ra开发者_StackOverflowtio proportionate?

Thanks for any suggestions.


try

$('img').load(function(){
    $(this).css('width', function(i,width){
        return (parseInt(width) > 500)? '500px':width;
    });
})

required jQuery 1.4

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜