repeatCount屬性指定動畫的持續時間。使用此屬性的元素包括<animate>,<animateColor>,<animateMotion>,<animateTransform>和<set>
用法:
repeatCount = number || indefinite
屬性值:repeatCount屬性接受上麵提到和下麵描述的值。
- number:它指示迭代次數。值開始大於0或更大。
- indefinite:它指定動畫將無限期重複。
範例1:下麵的示例說明了repeatCount屬性的用法。
HTML
<!DOCTYPE html>
<html>
<body>
<div style="color:green;
text-align:center;">
<h1>GeeksforGeeks</h1>
<h4>It will stop after 6 sec.</h4>
<svg viewBox="0 0 620 150"
xmlns="http://www.w3.org/2000/svg">
<rect x="260" y="0" fill="green"
width="100" height="100">
<animate attributeType="XML"
attributeName="y" from="0"
to="50" dur="1s" repeatCount="6" />
</rect>
</svg>
</div>
</body>
</html>
輸出:
範例2:
HTML
<!DOCTYPE html>
<html>
<body>
<div style="color:green;
text-align:center;">
<h1>GeeksforGeeks</h1>
<h4>It will continue to animate</h4>
<svg viewBox="0 0 620 150"
xmlns="http://www.w3.org/2000/svg">
<rect x="260" y="0" fill="green"
width="100" height="100">
<animate attributeType="XML"
attributeName="y" from="0"
to="50" dur="1s"
repeatCount="indefinite" />
</rect>
</svg>
</div>
</body>
</html>
輸出:
相關用法
- SVG viewBox屬性用法及代碼示例
- SVG rx屬性用法及代碼示例
- SVG width屬性用法及代碼示例
- SVG opacity屬性用法及代碼示例
- SVG stroke-width屬性用法及代碼示例
- SVG stroke屬性用法及代碼示例
- SVG height屬性用法及代碼示例
- SVG ry屬性用法及代碼示例
- SVG fill屬性用法及代碼示例
- SVG font-size屬性用法及代碼示例
- SVG stroke-dasharray屬性用法及代碼示例
- SVG cx屬性用法及代碼示例
- SVG flood-opacity屬性用法及代碼示例
- SVG filter屬性用法及代碼示例
- SVG font-style屬性用法及代碼示例
- SVG flood-color屬性用法及代碼示例
- SVG fill-opacity屬性用法及代碼示例
注:本文由純淨天空篩選整理自thacker_shahid大神的英文原創作品 SVG repeatCount attribute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。