Pure CSS3 typing animation with steps()

steps() is a relatively new addition to the CSS3 animations module. Instead of interpolating the values smoothly, it allows us to define the number of “frames” precisely. So I used it to create headers that have the well-known animated “typing effect”:…


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou

steps() is a relatively new addition to the CSS3 animations module. Instead of interpolating the values smoothly, it allows us to define the number of “frames” precisely. So I used it to create headers that have the well-known animated “typing effect”:

As you can see, the number of characters is hardcoded in the steps() function, but that’s the only place. Everything else is totally flexible. Apart from the font: It has to be monospace, so that every character has the same width.

Also, this particular way requires a solid background and an extra <span>. You can avoid these limitations by directly animating the width of the heading itself, but this requires a fixed target width hardcoded in the animation, so 2 things that need to be changed for every heading:

If you’re having trouble understanding how it works, take a look at this simpler example, with just the cursor.

Gecko (Firefox) and Webkit only at the moment, since other engines haven’t implemented CSS animations yet. However, both examples degrade very gracefully in other browsers (IMO at least).


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou


Print Share Comment Cite Upload Translate Updates
APA

Lea Verou | Sciencx (2011-09-05T00:00:00+00:00) Pure CSS3 typing animation with steps(). Retrieved from https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/

MLA
" » Pure CSS3 typing animation with steps()." Lea Verou | Sciencx - Monday September 5, 2011, https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/
HARVARD
Lea Verou | Sciencx Monday September 5, 2011 » Pure CSS3 typing animation with steps()., viewed ,<https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/>
VANCOUVER
Lea Verou | Sciencx - » Pure CSS3 typing animation with steps(). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/
CHICAGO
" » Pure CSS3 typing animation with steps()." Lea Verou | Sciencx - Accessed . https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/
IEEE
" » Pure CSS3 typing animation with steps()." Lea Verou | Sciencx [Online]. Available: https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/. [Accessed: ]
rf:citation
» Pure CSS3 typing animation with steps() | Lea Verou | Sciencx | https://www.scien.cx/2011/09/05/pure-css3-typing-animation-with-steps/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.