主頁
CSS
CSS 動畫
試一試:使用速記動畫屬性
執行 ❯
建立您
自己的
網站
×
改變方向
儲存程式碼
改變主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> div { width: 100px; height: 100px; background-color: red; position: relative; animation: myfirst 5s linear 2s infinite alternate; } @keyframes myfirst { 0% {background-color:red; left:0px; top:0px;} 25% {background-color:yellow; left:200px; top:0px;} 50% {background-color:blue; left:200px; top:200px;} 75% {background-color:green; left:0px; top:200px;} 100% {background-color:red; left:0px; top:0px;} } </style> </head> <body> <h1>CSS Animation</h1> <p>This example uses the shorthand animation property:</p> <div></div> </body> </html>