ใช้คุณสมบัติ animation-iteration-count เพื่อกำหนดจำนวนครั้งที่แอนิเมชันควรทำงาน
ตัวอย่างโค้ด
ตัวอย่างต่อไปนี้ตั้งค่าจำนวนรอบของแอนิเมชันเป็น 2:
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 150px;
height: 200px;
background-color: yellow;
animation-name: myanim;
animation-duration: 2s;
animation-iteration-count: 2;
}
@keyframes myanim {
from { background-color: green; }
to { background-color: blue; }
}
</style>
</head>
<body>
<div></div>
</body>
</html>
ค่าที่เป็นไปได้:
- ตัวเลข:
1,2,3... (จำนวนรอบ) infinite- ทำงานวนลูปตลอดไป
ค่าเริ่มต้นคือ 1 รอบเดียว