如何为 Ionicon 的颜色设置动画?
How to animate the color of an Ionicon?
我想要一个 ionicon(猜猜它的 SVG)来迭代改变颜色。我尝试了以下方法,但它只显示紫色的 svg 图标:
元素
<a class="ion-social-twitter button-home"></a>
css
.button-home {
fill: #fff;
-webkit-animation: animation-button 20000ms infinite;
-moz-animation: animation-button 20000ms infinite;
-o-animation: animation-button 20000ms infinite;
animation: animation-button 20000ms infinite;
font-size: 25vh;
}
@-webkit-keyframes animation-button {
0% {fill:red; }
25% {fill:yellow; }
50% {fill:blue; }
75% {fill:green; }
100% {fill:red; }
}
@keyframes animation-button {
0% {fill:red; }
25% {fill:yellow; }
50% {fill:blue; }
75% {fill:green; }
100% {fill:red; }
}
您使用 ionicons 作为字体。只需将 fill
更改为 color
,就像这样 -
@-webkit-keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
@keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
这里是 Bootstrap 字形的演示。
它的图标类型 字体,所以你可以使用 color
(不是 fill
)
.button-home {
color: #fff;
-webkit-animation: animation-button 20000ms infinite;
-moz-animation: animation-button 20000ms infinite;
-o-animation: animation-button 20000ms infinite;
animation: animation-button 20000ms infinite;
font-size: 25vh;
}
@-webkit-keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
@keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
我想要一个 ionicon(猜猜它的 SVG)来迭代改变颜色。我尝试了以下方法,但它只显示紫色的 svg 图标:
元素
<a class="ion-social-twitter button-home"></a>
css
.button-home {
fill: #fff;
-webkit-animation: animation-button 20000ms infinite;
-moz-animation: animation-button 20000ms infinite;
-o-animation: animation-button 20000ms infinite;
animation: animation-button 20000ms infinite;
font-size: 25vh;
}
@-webkit-keyframes animation-button {
0% {fill:red; }
25% {fill:yellow; }
50% {fill:blue; }
75% {fill:green; }
100% {fill:red; }
}
@keyframes animation-button {
0% {fill:red; }
25% {fill:yellow; }
50% {fill:blue; }
75% {fill:green; }
100% {fill:red; }
}
您使用 ionicons 作为字体。只需将 fill
更改为 color
,就像这样 -
@-webkit-keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
@keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
这里是 Bootstrap 字形的演示。
它的图标类型 字体,所以你可以使用 color
(不是 fill
)
.button-home {
color: #fff;
-webkit-animation: animation-button 20000ms infinite;
-moz-animation: animation-button 20000ms infinite;
-o-animation: animation-button 20000ms infinite;
animation: animation-button 20000ms infinite;
font-size: 25vh;
}
@-webkit-keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}
@keyframes animation-button {
0% {color:red; }
25% {color:yellow; }
50% {color:blue; }
75% {color:green; }
100% {color:red; }
}