Kevin
Kevin

Reputation: 567

resize image based on browser resize (and keeping dimensions)

Google recently added backgrounds to it's home page .. Like it or hate it, it's got the ability to resize the background image while keeping the same proportions as the browser window resizes...

Anyone know of any jQuery to do that?

Upvotes: 0

Views: 697

Answers (2)

Dan Heberden
Dan Heberden

Reputation: 11068

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

Upvotes: 0

Babiker
Babiker

Reputation: 18798

Width is set to a percentage.

Upvotes: 3

Related Questions