3

I want an ionicon (guess its SVG) to iteratively change color. I tried the following, but it only shows the svg icon in purple:

element

<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; }
}
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
WJA
  • 6,676
  • 16
  • 85
  • 152

2 Answers2

1

You use ionicons as font. Just change the fill to color, like this -

@-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; }
}

Here a demo with Bootstrap Glyphicons.

Fiddle

Ramiz Wachtler
  • 5,623
  • 2
  • 28
  • 33
1

Its type of icon font, So tyr to use color (not 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; }
}
l2aelba
  • 21,591
  • 22
  • 102
  • 138