Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style>
img.a {
  width: 200px;
  height: 400px;
  object-fit: cover;
}
</style>
</head>
<body>
<h2>The object-fit Property</h2>
<h2>object-fit: cover:</h2>
<p>Cut off the sides of an image, preserving the aspect ratio, and also filling in the space:</p>
<img class="a" src="paris.jpg" alt="Paris" width="400" height="300">
<h2>Original image:</h2>
<img src="paris.jpg" alt="Paris" width="400" height="300">
<p>Note: The object-fit property is not supported in Internet Explorer/Edge 15 or earlier.</p>
</body>
<!-- Mirrored from www.w3schools.com/cssref/tryit.asp?filename=trycss3_object-fit by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 15:17:10 GMT -->
</html>