2
我有一個SVG動畫,我想用css設置animate
標籤屬性from
和to
。從css中設置svg animate的屬性
喜歡:
animate{
from: #f7f7f7;
to: #33d424;
}
這是可能的,我該怎麼辦呢?
這裏是我的SVG代碼:
<svg width='100px' height='100px' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-squares">
<rect x="0" y="0" width="100" height="100" fill="none" class="bk"></rect>
<rect x="15" y="15" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.0s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="40" y="15" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.125s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="65" y="15" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.25s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="15" y="40" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.875s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="65" y="40" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.375" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="15" y="65" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.75s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="40" y="65" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.625s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
<rect x="65" y="65" width="20" height="20" fill="#f7f7f7" class="sq">
<animate attributeName="fill" from="#f7f7f7" to="#33d424" repeatCount="indefinite" dur="1s" begin="0.5s" values="#33d424;#33d424;#f7f7f7;#f7f7f7" keyTimes="0;0.1;0.2;1"></animate>
</rect>
</svg>
這是不可能的。動畫屬性不是CSS屬性。 – 2015-04-03 07:24:51