Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

ตั้งชื่อ CSS @keyframes Animation ด้วย animation-name

ใช้คุณสมบัติ animation-name เพื่อตั้งชื่อของ @keyframes animation

ตัวอย่าง

<!DOCTYPE html> <html>    <head>       <style>          div {             width: 150px;             height: 200px;             position: relative;             background: red;             animation-name: myanim;             animation-duration: 2s;          }          @keyframes myanim {             from {left: 0px; background-color: green;}             to {left: 100px; background-color: blue;}          }       </style>    </head>    <body>       <div></div>    </body> </html>