view { width: 100px; height: 100px; background-color: red; border-radius: 50%; } .one { animation: move1 5s infinite alternate; } .two { background-color: blue; position: absolute; left: 0px; top: 150px; animation: move2 5s infinite alternate; } @keyframes move1 { 0% { transform: translateX(0); } 100% { transform: translateX(250px); } } @keyframes move2 { 0% { left: 0px; } 100% { left: 250px; } }