Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looping Animation of text color change using CSS3

Tags:

I have text that I want to animate. Not on hover, for example but continually changing slowly from white to red and then back to white again.

Here is my CSS code so far:

#countText{     color: #eeeeee;     font-family: "League Gothic", Impact, sans-serif;     line-height: 0.9em;     letter-spacing: 0.02em;     text-transform: uppercase;     text-shadow: 0px 0px 6px ;     font-size: 210px; } 
like image 513
Alex Jj Avatar asked May 28 '13 01:05

Alex Jj


People also ask

How do you change the color of text in CSS?

Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.

Which CSS property is used to change the text color?

The color property is used to set the color of the text. The color is specified by: a color name - like "red" a HEX value - like "#ff0000"


1 Answers

Use keyframes and animation property

p {   animation: color-change 1s infinite; }  @keyframes color-change {   0% { color: red; }   50% { color: blue; }   100% { color: red; } }
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui ad quos autem beatae nulla in.</p>

CSS With Prefixes

p {     -webkit-animation: color-change 1s infinite;     -moz-animation: color-change 1s infinite;     -o-animation: color-change 1s infinite;     -ms-animation: color-change 1s infinite;     animation: color-change 1s infinite; }  @-webkit-keyframes color-change {     0% { color: red; }     50% { color: blue; }     100% { color: red; } } @-moz-keyframes color-change {     0% { color: red; }     50% { color: blue; }     100% { color: red; } } @-ms-keyframes color-change {     0% { color: red; }     50% { color: blue; }     100% { color: red; } } @-o-keyframes color-change {     0% { color: red; }     50% { color: blue; }     100% { color: red; } } @keyframes color-change {     0% { color: red; }     50% { color: blue; }     100% { color: red; } } 
like image 107
Sourabh Avatar answered Sep 19 '22 14:09

Sourabh