I need to display a bunch of images on a page. Images are of different sizes, some are very wide and very thin. I want to put them in a container with a fixed width and a fixed height.
Say if the image is smaller, we save the size and place it in the center of the container. if the image is larger, we scale it according to the visible direction.
Our container is 500x500, and the image say 1000x400, then it will scale as 500x200. Similarly, if the image is 400x1000, then the scaled image is 200x500. This can only be done using html / css. Any help is appreciated. Thank.
source
share