views:

38

answers:

1

So this is increasing the size of the image, relative to the original size of the image:

$('img:first').fadeIn('normal').delay(500).animate({'height':'+=20%'}, 1500, 'easeOutQuad');

How do I increase it, to say 80% of the user's window (this should work if the user has an 800px resolution monitor, or 1680px resolution monitor).

Also, how do I 'center' the image in the page. So increase to 80% and center.

Thanks.

+2  A: 

This is a start...

$('img:first').fadeIn('normal').delay(500).animate({
    'width': $(window).width() * .8,
    'height': $(window).height() * .8
}, 1500, 'easeOutQuad');

but it will likely mess up the image's aspect ratio. To do it properly, you'll have to get the dimensions of the image and figure out what ratio will yield the margins you want without altering the aspect ratio. That will require a bit more code.

harpo
This is definitely a good start.Thanks.
marcamillion
I forgot to mention... you'll probably also want to set position:fixed on the container (or at least position:absolute). That will allow you to center the image by setting top and left.
harpo