JsFiddle Demo
div { width: 200px; height: 200px; overflow: hidden; margin: 10px; position: relative; } img { position: absolute; margin: auto; min-height: 100%; min-width: 100%; left: -100%; right: -100%; top: -100%; bottom: -100%; }
Update - Improvement
As Salman A mentioned in the comments, the original solution has a drawback - it does not work if the height or width of img (or both) (at least) is 3 times * larger than the containing div.
The problem is displayed here .
Salman also gave a really simple and elegant solution. We just need to update the coordinates of the img position (top, left, bottom, right) to work with higher percentages. The following fix works with 1000%, but of course you can customize it according to your needs.
the working version is shown here .

* The reason is that when we set the img left and right (or: top and bottom) coordinates to -100% (of the containing div), the total allowable width (or: height) of img can be equal to at most 300% of the containing div (or: height), because this is the sum of the width of the div (or: height) and the left and right (or: upper and lower) coordinates.
Itay Sep 07 '13 at 14:08 2013-09-07 14:08
source share