Home > Software design >  Is there an CSS feature to fit to the content of image?
Is there an CSS feature to fit to the content of image?

Time:11-07

Fit to content

I want to make an image to fit the content.
Trimming transparent background will be needed if it is done with a photo editor.

Is there any way to deal with CSS?
Or do I have to edit image before using it?

Thanks in advance!

What I have researched about css feature:

  • object-fit: It was a little more about aspects

CodePudding user response:

There is no such feature in CSS as far as I can tell.

However, there are two possible solutions fixing your problem.

If it has to be done for an already known image:

  • You could manually scale the image using background-size and background-position so it does only show the area of the image you need.

If it has to be done for an unknown image:

  • Related