<h1>Animating the <code>object-position</code> Property</h1>

<figure>
  <img  class="ltr" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/123941/sunset.jpg" />
  <figcaption>An Awesome Sunset</figcaption>
</figure>
body {
  text-align: center;
}

figure {
  position: relative;
  display: inline-block;
  margin: 0;
}

figcaption {
  position: absolute;
  top: 20px;
  left: 20px;
  background: black;
  color: white;
  padding: 8px 15px;
}

img {
  width: 540px;
  height: 480px;
  border: 10px solid black;
  background: yellow;
  object-fit: cover;
  animation: ltr 3s alternate infinite;
}

@keyframes ltr {
  0% {
    object-position: 0% 0%;
  }
  50% {
    object-position: 20% 0%;
  }
  100% {
    object-position: 100% 100%;
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.