cssoverflowscaledistortion

CSS image scaling to fit within area not distort


Is there a way with CSS or otherwise of making an image fit within an area. Lets say I have multiple images of different sizes and I want them all to fit within a div of 150px by 100px. I don't want to scale the images though as some may be tall and others narrow I simply want them to fit within this area with the rest hidden.

I thought about using overflow:hidden but it appears to not be hidden in IE6.

Any ideas?


Solution

  • I know this is an old one, but because I found it in search of answer for the same question, I guess it could be of use for someone else, too.

    Since the answers were posted, CSS property object-fit was brought to us. It does exactly what was once requested in the question.

    For reference: https://www.w3schools.com/css/css3_object-fit.asp