Clip images with HTML and CSS

Francisc picture Francisc · Aug 17, 2011 · Viewed 12.8k times · Source

I want to display images in a 144px x 144px div element. Images are always larger than 144px and so I want to zoom scale them. By that I mean that the smallest side will touch the edge of the div, cutting a bit from the other side - the opposite of letterbox.

How can I do this and have it work on older browsers like IE as well?

EDIT:
Changed the image, the first was wrong, sorry. Resize the image so that inside the div there is no space without image
enter image description here

Answer

Cfreak picture Cfreak · Aug 17, 2011

Set only the width of the image to 144px in CSS or in the attribute. The height will scale automatically. I'm fairly certain this works as low as IE 6. I'm not certain about anything older than that.