HTML
CSS
JavaScript
<div class='container'> <div class='box'> Move Me! </div> </div>
.container { width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; background-color: #f0f0f0; } .box { width: 100px; height: 100px; background-color: #3498db; color: white; display: flex; justify-content: center; align-items: center; font-size: 16px; animation: move 2s infinite alternate; offset-anchor: 50% 50%; } @keyframes move { 0% { transform: translate(0, 0); } 100% { transform: translate(200px, 200px); } }
// No JavaScript required for this demo
Move Me!