Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a delay between cycles of css animation [duplicate]

Tags:

html

css

I am rotating a circular <div> infinity in 360 degrees using css animation. After each rotation, I want a halt or delay of 5 seconds before next rotation. How can I achieve it?

Here's a live example

Code is as following.

CSS

.circle{
    position: absolute;
    top: 4;
    right: 4;
    height: 21px;
    width: 21px;
    border-radius: 50%;
    background: #00B5F9;
    color: white;
    font-family: varela round;
    font-size: 11;
    font-weight: 500;
    border: 1px solid white;
    -webkit-animation-name: lol;
    -webkit-animation-duration: 1s;
    -webkit-animation-timing-function:  ease-in-out;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-delay: 1s
}
@-webkit-keyframes lol {  
    0% { -webkit-transform:rotate(0deg) }

    100% { -webkit-transform:rotate(360deg) }

}

HTML

<div class="circle">56</div>
like image 476
Aditya Ponkshe Avatar asked Feb 11 '23 20:02

Aditya Ponkshe


1 Answers

You can do something like this.

0% { -webkit-transform:rotate(0deg) }
20% { -webkit-transform:rotate(360deg) }
100% { -webkit-transform:rotate(360deg) }

and change the duration of the rotation

-webkit-animation-duration: 6s;

So what you are doing is setting the animation to take 6's but moving the rotation to be quicker (20% is not correct for 5's wait but you can work it out). So the rotate happens and then it sits at 360deg for the remainder of the time.

Demo Here

like image 73
Ruddy Avatar answered Feb 16 '23 02:02

Ruddy