@asimovwasright的答案是正确的。
为了避免在CSS上发生太多重复,我将@for
SCSS与一起使用,以遍历所有可用范围(在本例中为8)
.hey {
span {
color: transparent;
animation: heyThere 500ms ease-out;
animation-fill-mode: forwards;
$chars: 8;
@for $i from 1 through $chars {
&:nth-of-type(#{$i}) {
animation-delay: 1200+70ms*$i;
}
}
}
}
和HTML:
<h2 class="hey">
<span>H</span>
<span>e</span>
<span>y</span>
<br>
<span>t</span>
<span>h</span>
<span>e</span>
<span>r</span>
<span>e</span>
</h2>