Is there way to animate each letter in a word separately, using only CSS?
I guess it’s possible to do, using javascript/jquery, iterating over the word as an array of letters.
But here I’m looking for an easy way out..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Whether you do it with CSS or JavaScript, you (or some library) are going to have to put each letter in its own element in order to animate them individually. E.g.:
…will need to become
That leads me to think a JavaScript solution might be preferred, as otherwise your markup will be a bit…unpleasant to write.
With JavaScript using jQuery, it’s quite easy to replace the text of an element with a bunch of spans containing that text character-by-character:
Then you animate the
spans. (Note I’m assuming here that the element in question contains only text, not text and child elements. It’s more complex if you have child elements.)Here’s a very basic example:
HTML:
JavaScript:
Live copy | source