Size image to container while maintaing aspect ratio in CSS?

adaaamm

New Member
I have a bunch of images of different (unknown) dimensions.I want to drop these images into a div and have them automatically conform to the dimensions of the div, while maintaining their aspect ratio. In other words, if the image is wider than high, the width will be 100%, and the height will scale accordingly. If the image is higher than wide, the height will be 100%, and the width will scale accordingly.Is there any way to do this in pure css?Thanks
 
Back
Top