I want to show an image in a div in a following way:
If image own size is smaller than div by both x and y axes, then it must be centered like so:
If the image is bigger than div by one axis, then it must be downscaled keeping aspect ratio to fit div by that axis, and be centered by another axis like so:
or so:
I could do that using JavaScript, handling window resize etc, but I would like to achieve that with HTML/CSS only. Is it possible? How if it is? Why if it is not?