Answer the question
In order to leave comments, you need to log in
How to implement animated appearance of text by letter?
Good day.
On the site: https://greenthumb.themerex.net/ there is a slider on top, the text appears on it letter by letter.
How can such an effect be realized? In this example, each letter is broken into its own container and appears separately. Perhaps there are similar examples for "parsing".
Answer the question
In order to leave comments, you need to log in
There was a solution in pure JS and CSS.
JS
function animateWord(word){
let text = word.dataset.text;
text.split('').forEach((letter,ind) => {
let div = document.createElement('div');
div.innerText = letter;
setTimeout(()=> word.append(div),ind*200);
})
}
const word = document.querySelector('.word');
animateWord(word);
@keyframes letter{
0% {opacity: 0; transform: translateY(-15px)}
100% {opacity: 1; transform: translateY(0px)}
}
.word div {
animation: letter 0.5s;
display: inline-block;
}
<div class="word" data-text='Hello'></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question