<div class="none">None</div>

<hr>

<div class="forwards">Forwards</div>

<hr>

<div class="backwards">Backwards</div>

<hr>

<div class="both">Both</div>
@keyframes change-bg-color {
  0% {
    background-color: white;
  }
  25% {
    background-color: bisque;
  }
  50% {
    background-color: crimson;
  }
  100% {
    background-color: darkviolet;
  }
}

.none {
  padding: 10px;
  margin: auto;
  border: 2px solid darkviolet;
  border-radius: 10px;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;

  color: darkviolet;
  width: 200px;

  animation-name: change-bg-color;
  animation-duration: 5s;
  
  animation-timing-function: ease-in-out;
  animation-delay: 2s;
  
  animation-fill-mode: none;
}

.forwards {
  padding: 10px;
  margin: auto;
  border: 2px solid darkviolet;
  border-radius: 10px;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;

  color: darkviolet;
  width: 200px;

  animation-name: change-bg-color;
  animation-duration: 5s;
  
  animation-timing-function: ease-in-out;
  animation-delay: 2s;
  
  animation-fill-mode: forwards;
}

.backwards {
  padding: 10px;
  margin: auto;
  border: 2px solid darkviolet;
  border-radius: 10px;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;

  color: darkviolet;
  width: 200px;

  animation-name: change-bg-color;
  animation-duration: 5s;
  
  animation-timing-function: ease-in-out;
  animation-delay: 2s;
  
  animation-fill-mode: backwards;
}

.both {
  padding: 10px;
  margin: auto;
  border: 2px solid darkviolet;
  border-radius: 10px;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;

  color: darkviolet;
  width: 200px;

  animation-name: change-bg-color;
  animation-duration: 5s;
  
  animation-timing-function: ease-in-out;
  animation-delay: 2s;
  
  animation-fill-mode: both;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.