运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <style> div { width: 100px; height: 100px; background: red; position: relative; animation: myfirst 5s 2; animation-direction: alternate; } @keyframes myfirst { 0% {background: red; left: 0px; top: 0px;} 25% {background: yellow; left: 200px; top: 0px;} 50% {background: blue; left: 200px; top: 200px;} 75% {background: green; left: 0px; top: 200px;} 100% {background: red; left: 0px; top: 0px;} } </style> </head> <body> <h1>animation-direction: alternate</h1> <p>Play the animation forwards first, then backwards:</p> <div></div> </body> </html>