crop background image css code example

Example 1: image crop using css 1:1

.img {
	object-fit: cover;         
  	object-position: 100% 0;  //move image position in x direction. 
  	object-position: 0 100%; //move image position in y direction.
}

Example 2: style image so it crops

.alligator-turtle {
  object-fit: cover;
  object-position: 100% 0;

  width: 300px;
  height: 337px;
}

Example 3: crop image css

.img {
  object-fit: contain;
}

Example 4: how to crop images in css

img{
	object-fit: cover;
}

Example 5: trim background image css

.tiledBackground {
  background-image: url(https://www.mozilla.org/media/img/logos/firefox/logo-quantum.9c5e96634f92.png);
  background-size: 150px;
  width: 300px;
  height: 300px;
  border: 2px solid;
  color: pink;
}

Tags:

Css Example