DEV Community

Stephanie Eckles
Stephanie Eckles

Posted on

34 11

Pure CSS Typing Animation

With the use of keyframe animations, and a couple of (forgivable) magic numbers, we can create a pure CSS typing animation!

We use two keyframe animations - one for the cursor, one for the "typing" reveal of the letters.

A major advantage of this technique is the text being "typed" is always accessible via assistive tech as well as for things like SEO crawlers because we are using overflow: hidden. So it is only visually hidden temporarily while the full word is available in the DOM at all times.

You can borrow this animation, but it will require a bit of finessing by updating the following if you change the word and/or typeface:

// "Type" width 
// - controls how much the word container expands when each letter is "typed"
// - will need adjusted depending on word and typeface
$chWidth: .49em;
// Word length
$chCount: 9;
// Typing animation length
$typeDuration: 180ms * $chCount; 
Enter fullscreen mode Exit fullscreen mode

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (2)

Collapse
 
ajeebkp23 profile image
Ajeeb.K.P • Edited

Hi, this is really cool. Thanks for sharing the trick.

By the way, Is it liberally licensed. Or free to use for ?

Collapse
 
5t3ph profile image
Stephanie Eckles

Feel free to use!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay