最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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...

发布评论

评论列表(0)

  1. 暂无评论