How to fix object-fit not affecting images with CSS?

Spread the love

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.

Leave a Reply

Your email address will not be published. Required fields are marked *