Position absolute

by wistcc

HTML

<div class="container">
  <div class="box box1">
  </div>
  <div class="box box2">
  </div>
  <div class="box box1">
  </div>
</div>

CSS

.container {
  width: 218px;
  padding: 30px;
  border: 1px solid black;
  margin: 30px;
}

.box {
  width: 50px;
  height: 50px;
  margin: 10px;
  display: inline-block;
}

.box1 {
 background-color: red; 
}

.box2 {
 background-color: blue; 
 position: absolute;
 animation: move ease 5s alternate infinite;
 animation-delay: 1.5s;
}

@keyframes move {
  0% {
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
  }
  25% {
    left: 0;
    top: 0;
    right: 0;
    bottom: 50%;
  }
  50% {
    left: 0;
    top: 0;
    right: 50px;
    bottom: 0;
  }
  75% {
    left: 0;
    top: 50px;
    right: 0;
    bottom: 0;
  }
  100% {
    left: 50px;
    top: 0;
    right: 0;
    bottom: 0;
  }
}