
How to Play Animations Infinitely in CSS
In order to play CSS animations indefinitely, all you have to do is set the animation-iteration-count property to infinite.
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loading-circle {
/* We need βlinearβ for smooth transition */
animation: rotate 2s linear;
animation-iteration-count: infinite;
} Make sure that you return to the initial state in order to create a smooth animation. You can also set an arbitrary number as the iteration count to repeat the animation a number of times.
/* This will play the animation twice */
.animation {
animation-iteration-count: 2;
} You can also use a shorthand property, where you can define the animation-iteration-count as the very last rule:
.loading-circle {
animation: rotate 2s linear infinite;
} 

Resources:

Rocket Launch Your Career
Speed up your learning progress with our mentorship program. Join as a mentee to unlock the full potential of Webtips and get a personalized learning experience by experts to master the following frontend technologies:
Courses

CSS - The Complete Guide (including Flexbox, Grid and Sass)

The HTML & CSS Bootcamp




