This is my animation:
.ani span {
animation: animation 1s infinite;
display: inline-table;
}
@keyframes animation {
0% {
transform: translateY(0px);
}
33.333% {
transform: translateY(-5px);
}
66.666% {
transform: translateY(5px);
}
100% {
transform: translateY(0px);
}
}
.ani span:nth-child(1) {
animation-delay: .1s;
}
.ani span:nth-child(2) {
animation-delay: .2s;
}
.ani span:nth-child(3) {
animation-delay: .3s;
}
.ani span:nth-child(4) {
animation-delay: .4s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="ani"><span>h</span><span>e</span><span>l</span><span>l</span><span>o</span></div>
I will have different texts (not only »hello«) that should have this animation. So it would be great to have it as jQuery function. There should be calculated the text length, automatically placed <span></span>
, and a fitting animation-delay
.
How is it possible to code that?
Would be sooooo thankful for help.