หากต้องการนำ animation ไปใช้กับคุณสมบัติ font-weight ใน CSS สามารถทดลองรันโค้ดตัวอย่างด้านล่างได้
ตัวอย่างโค้ด
<!DOCTYPE html> <html> <head> <style> p { border: 2px solid black; width: 400px; height: 100px; animation: myanim 5s infinite; } @keyframes myanim { 70% { font-weight: bold; } } </style> </head> <body> <p>This is demo text</p> </body> </html>
คำอธิบาย
ตัวอย่างนี้จะสร้าง animation ที่ทำให้ข้อความเปลี่ยนจากปกติเป็นหนา (bold) ที่ 70% ของระยะเวลา animation (5 วินาที) และทำซ้ำไปเรื่อยๆ (infinite) คุณสมบัติ font-weight สามารถทำ animation ได้ตั้งแต่ CSS3 แต่การรองรับอาจแตกต่างกันไปในแต่ละเบราว์เซอร์