We see that the image is being squished to fit the container of 200x300 pixels (its original aspect ratio is destroyed).
Here is where the object-fit
property comes in. The object-fit
property can take one of the following values:
fill
- This is default. The image is resized to fill the given dimension. If necessary, the image will be stretched or squished to fitcontain
- The image keeps its aspect ratio, but is resized to fit within the given dimensioncover
- The image keeps its aspect ratio and fills the given dimension. The image will be clipped to fitnone
- The image is not resizedscale-down
- the image is scaled down to the smallest version ofnone
orcontain
No comments:
Post a Comment