Resize image width in function of set image height in CSS?

by Joe   Last Updated August 07, 2019 08:10 AM

I'm trying to tell an image to be displayed with a maximum height of 400 pixels, and a width adapted onto the used height, with the following CSS - Code:

span.itemImage img {
    max-height:400px;
    width:auto;
}

With the code above, images don't exceed the height of 400 px; that works perfectly, but their width doesn't get adapted in function of the height they have. Anyone knows how to program that properly in CSS ?



Related Questions


Updated April 28, 2015 00:04 AM

Updated October 04, 2016 09:04 AM

Updated January 28, 2019 14:10 PM

Updated May 18, 2015 21:04 PM

Updated September 05, 2016 08:06 AM