Edit in JSFiddle

<div class="spring">
</div>
.spring {
  height: 100px;
  background-color: blue;
  animation: spring 2s linear 3s alternate-reverse 4 both;
}

@keyframes spring {
  0% {transform: scaleY(0.2); background-color: red;}
  40% {transform: scaleY(0.3);}
  60% {transform scaleY(0.5);}
  100% {transform: scaleY(1.2); background-color: green;}
}