To fix object-fit not affecting images with CSS, we set object-fit
to cover
.
For instance, we write
.myImg {
object-fit: cover;
max-width: 100%;
object-position: center;
}
to set the object-fit
to cover
to make the image fit in the img element boundaries.