Scale image by centering while maintaining aspect ratio using CSS
I want to create an image gallery like a mobile phone gallery. each image should be in a square box inside the main container.
The image should not stretch and not crop or clip. now i am stretching image with aspect ratio using this code,
img {
max-width : 150px;
max-height : 150px;
}
it gives me a reduced thumbnail of each image. but I want to do everything inside a square square with a clipped or cropped clip.
+3
source to share