Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <style> html, body { height: 100%; margin: 0; } body { display: flex; align-items: center; justify-content: center; } .element { height: 200px; width: 200px; background-color: #1c87c9; animation: nudge 6s ease infinite alternate, nudge 6s linear infinite alternate; } @keyframes nudge { 0%, 100% { transform: translate(0, 0); } 60% { transform: translate(150px, 0); } 80% { transform: translate(-150px, 0); } } </style> </head> <body> <div class="element"></div> </body> </html>