css crop image to fit div

Crop images to fit the dimensions of a div container is very easy with the following CSS lines:

img {
object-fit: cover;

This will center the image and adjust the image size to fit the borders of the div container. Most splendidly it will contain the dimensions of the image, so your site looks great!

Please do mind that in order for this to work you will have to set the height and width of the container div. These could of course be absolute pixels, a percentage or being calculated.