jquery - Resize images to be fullscreen with javascript? - Stack Overflow

Can you resize images to be fullscreen with javascript in the same way you can with flash? Ive found th

Can you resize images to be fullscreen with javascript in the same way you can with flash?

Ive found this link but its for an entire plugin with slideshow, etc not just the feature I need for a more custom design: /

And this plugin seems to only with with background images: .html

Ideally id like to do this with jQuery. Thanks

Can you resize images to be fullscreen with javascript in the same way you can with flash?

Ive found this link but its for an entire plugin with slideshow, etc not just the feature I need for a more custom design: http://buildinternet./project/supersized/

And this plugin seems to only with with background images: http://www.ajaxblender./bgstretcher-2-jquery-stretch-background-plugin-updated.html

Ideally id like to do this with jQuery. Thanks

Share Improve this question asked May 23, 2011 at 14:19 EvanssEvanss 23.2k101 gold badges322 silver badges556 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

Here's an example of a basic implementation. It accounts for resizing of the window, but doesn't account for any focus point of the image and so the focus point could fall out of view for oddly-sized windows.

http://jsbin./okizi5

Edit: I forgot to point that that the width/height attributes on the image are necessary in this version for all browsers (notably Safari) to calculate the aspect ratio of the image. If your image is to be dynamic and the dimensions are not available then these could be calculated within the 'load' function bound to the window.

Yes. I don't see why you can't, really. You can use JavaScript, and its DOM interface, to modify the style properties of an image to resize an image. You don't even need a heavy library like jQuery; it's all native.

How about this:

$(window).resize(function() {
    $('#myImgId').width($(window).width());
    $('#myImgId').height($(window).height());
});

It will not maintain the aspect ratio...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742421792a4440830.html

相关推荐

  • jquery - Resize images to be fullscreen with javascript? - Stack Overflow

    Can you resize images to be fullscreen with javascript in the same way you can with flash? Ive found th

    6小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信