DEV Community

Discussion on: What CSS tip do you want to share with others?

artemartemov profile image
Artem Artemov

yes pretty much! it is very helpful to preserve aspect ratio for both images and video.

so lets say you have a 2:1 image (and you cannot crop it down manually or via some upload tool) you can use object-fit: cover - so if the container that holds the image is a 1:1, it will not distort but in fact crop outside of the container.

Thread Thread
adrianmarkperea profile image
Adrian Perea Author