<div id="elems">
  <div class="box elem"></div>
  <div class="box elem"></div>
  <div class="box elem"></div>
</div>
.box{
  background-color: #ea0f9b;
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
}
var cssSelector = anime({
  targets: '#elems .elem',
  translateX: 250,
  duration: 1500,
  loop: true,
  direction: 'alternate'
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js