Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Align Images with Object Fit</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    p {
      margin-bottom: 3rem;
    }
    .ex-object-fit {
      height: 200px;
      overflow: hidden;
    }
    .ex-object-fit img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center;
    }
    .op-top img {
      object-position: top;
    }
    .op-bottom img {
      object-position: bottom;
    }
  </style>
</head>
<body>
  <div class="container-fluid text-center pt-5">
    <div class="ex-object-fit op-top">
      <img src="https://picsum.photos/id/63/1200/600" alt="Coffee?">
    </div>
    <p>Align top (object-position: top)</p>
    <div class="ex-object-fit">
      <img src="https://picsum.photos/id/63/1200/600" alt="Coffee?">
    </div>
    <p>Align center (object-position: center)</p>
    <div class="ex-object-fit op-bottom">
      <img src="https://picsum.photos/id/63/1200/600" alt="Coffee?">
    </div>
    <p>Align bottom (object-position: bottom)</p>
  </div>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
masoomulhaqspro
0viewers