akhunaton
akhunaton

Reputation: 41

Scale image height to browser window

Here is my image: http://cameronlimbrick.com/work/visual-art/paintings/item/thoughts

I would like to keep the existing maximum height, however, when the window is not tall enough to fit the entire image, I would like it to automatically shrink to fit the height. Thanks for your help.

Upvotes: 0

Views: 63

Answers (2)

Milad
Milad

Reputation: 859

It's should work!

$(document).ready(){
   var h = $(window).height();
   if (h < 755)
   {
       $('.img.your-image-class').css("max-height",h + "px")
   }
}

Upvotes: 1

Gershom Maes
Gershom Maes

Reputation: 8140

You could try

img.your-image-class {
    height: 100%; //automatically retains aspect ratio
    max-height: 755px; //don't let it get bigger than this (755px is its current height I checked your link
}

Upvotes: 1

Related Questions