https://baigie.me/officialblog/2021/02/25/css-tips-1/
上記サイトのその1を参考にし、一文字ずつ表示されるテキストアニメーションを実装しました。
これの場合、最後まで表示されるとまた文字が隠れていってしまうのですが、
そのまま表示させておくにはどうしたら良いでしょうか。
HTML
<h1 class="title"> <span>T</span> <span>E</span> <span>X</span> <span>T</span> <span> </span> <span>A</span> <span>N</span> <span>I</span> <span>M</span> <span>A</span> <span>T</span> <span>I</span> <span>O</span> <span>N</span> </h1>
CSS
.title { display: flex; overflow: hidden; color: #aa8f7b; font-family: 'Josefin Sans', sans-serif; } .title span { display: block; transform: translate(0, 105%); transition: transform cubic-bezier(0.215, 0.61, 0.355, 1) 0.5s; } .title.-visible span { transform: translate(0, 0); } .title span:nth-child(2) { transition-delay: 0.06s; } .title span:nth-child(3) { transition-delay: 0.12s; } .title span:nth-child(4) { transition-delay: 0.18s; } .title span:nth-child(5) { transition-delay: 0.24s; } .title span:nth-child(6) { transition-delay: 0.30s; } .title span:nth-child(7) { transition-delay: 0.36s; } .title span:nth-child(8) { transition-delay: 0.42s; } .title span:nth-child(9) { transition-delay: 0.48s; } .title span:nth-child(10) { transition-delay: 0.54s; } .title span:nth-child(11) { transition-delay: 0.6s; } .title span:nth-child(12) { transition-delay: 0.66s; } .title span:nth-child(13) { transition-delay: 0.72s; } .title span:nth-child(14) { transition-delay: 0.78s; }
JS
const CLASSNAME = "-visible"; const TIMEOUT = 1500; const $target = $(".title"); setInterval(() => { $target.addClass(CLASSNAME); setTimeout(() => { $target.removeClass(CLASSNAME); }, TIMEOUT); }, TIMEOUT * 2);

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/04/14 11:56