Skip to content

Instantly share code, notes, and snippets.

@UVLabs
Last active March 3, 2016 17:38
Show Gist options
  • Save UVLabs/c09014208c33c6752820 to your computer and use it in GitHub Desktop.
Save UVLabs/c09014208c33c6752820 to your computer and use it in GitHub Desktop.
Automatically cycle css colors. Property used here was color for text color. Could be replaced with "background" for background color of an element.
.element{
animation: colorchange 5s linear infinite; /* animation-name followed by duration in seconds*/
/* you could also use milliseconds (ms) or something like 2.5s */
-webkit-animation: colorchange 5s linear infinite; /* Chrome and Safari */
-moz-animation: colorchange 5s linear infinite; /* Firefox */
-o-animation: colorchange 5s linear infinite; /* Opera */
}
@keyframes colorchange
{
0% {color: yellow;}
25% {color: lime;}
50% {color: yellow;}
75% {color: #F05458;}
100% {color: yellow;}
}
@-webkit-keyframes colorchange /* Safari and Chrome - necessary duplicate */
{
0% {color: yellow;}
25% {color: lime;}
50% {color: yellow;}
75% {color: #F05458;}
100% {color: yellow;}
}
@-moz-keyframes colorchange /* Firefox - necessary duplicate */
{
0% {color: yellow;}
25% {color: lime;}
50% {color: yellow;}
75% {color: #F05458;}
100% {color: yellow;}
}
@-o-keyframes colorchange /* Opera - necessary duplicate */
{
0% {color: yellow;}
25% {color: lime;}
50% {color: yellow;}
75% {color: #F05458;}
100% {color: yellow;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment