DEV Community

Brandon Weaver
Brandon Weaver

Posted on

2 1

Cropping Images with CSS

There are a few ways to crop images using CSS.

The first approach is to use a container with relative positioning and hidden overflow, then adjust the orientation of the image using absolute positioning.

The second approach is to simply use object-fit and object-position to adjust the size and orientation of the image.

Here's a straight-forward example of the two strategies at work.

Top comments (0)

AI Agent image

How to Build an AI Agent with Semantic Kernel (and More!)

Join Developer Advocate Luce Carter for a hands-on tutorial on building an AI-powered dinner recommendation agent. Discover how to integrate Microsoft Semantic Kernel, MongoDB Atlas, C#, and OpenAI for ingredient checks and smart restaurant suggestions.

Watch the video ๐Ÿ“บ

๐Ÿ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someoneโ€™s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay