CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <style> #container1, #container2 { display: flex; justify-content: center; align-items: center; color: #fff; font-size: 20px; font-weight: bold; width: 120px; height: 100px; position: absolute; box-shadow: 0 0 10px 0 #aaa; } #container1 { background: #f00; right: 0; animation: anim1 5s infinite; } #container2 { background: #00f; bottom: 0; right: calc(100% - 120px); animation: anim2 5s infinite; } @keyframes anim1 { 50% {right: calc(100% - 120px);} } @keyframes anim2 { 50% {right: 0;} } </style> </head> <body> <h1>Animatable 'right' Property</h1> <hr> <p>Experience the changing position of the container using right property.<p> <div id="container1">Container 1</div> <div id="container2">Container 2</div> </body> </html>