可以使用 css 更改 svg 填充。但是我没有设法创建动画。 这是我的 svg 对象:
<svg version="1.1" id="tick" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 60 60" enable-background="new 0 0 60 60" xml:space="preserve">
<rect id="fill" x="21" y="26" width="60" height="60"/>
</svg>
并且,使用 SASS:
@include keyframes(loading)
0%
fill: black
50%
fill: white
100%
fill: black
#fill
fill: white
@include animation(loading 3s infinite)
我做错了什么?
最佳答案
编辑
好的,看起来像这样的东西应该可以工作。
<svg version="1.1" id="tick" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 60 60" enable-background="new 0 0 60 60" xml:space="preserve">
<style type="text/css" >
<![CDATA[
@keyframes fill {
0% {
fill: black;
}
50% {
fill: white;
}
100% {
fill: black;
}
}
#fill {
fill: black;
animation-name: fill;
animation-duration: 3s;
animation-iteration-count: infinite;
}
]]>
</style>
<rect id="fill" x="21" y="26" width="60" height="60"/>
</svg>
关于css - 使用 css 动画 svg 路径填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14756422/