Hello,
In the article Images, media, and form elements and Sizing items in CSS is described a problem concerning sizing of the images in relation to the boxe’s size they are in.
So I would like to understand, what is the difference between object-fit: contain
and max-width: 100%; max-height: 100%
?
As I see, in the first case we set two dimensions of the image to fixed 100% and specify object-fit: contain;
rule. In the second case we add two rules max-width and max-height accordingly. The effect is, in both cases, that we get an image fitted in the box dimensions saving its aspect ratio.