@keyframes and animation:

The cycle:

if i have an element that has some styles like:

        
            div{
                width:20px;
                color:purple;
                background:white;
            }
        
    

by default when the page run they will run(or they might work on any event).these styles will keep runing until the point the browser reaches the animation property:

        
            div{
            width:20px;
                color:purple;
                background:white;
                animation:jump 3s 2 3 ease;
            }
        
    

now the animation property will start runing and style the element with it's value.in our case jump 3s 2 3 ease.at that point @keyframes will begin running it's frames(0%,50%,...):

        
            @keyframes{
            0%{
              styles
            }
            50%{
              styles
            }
            100%{
              styles
            }
        
    

you need to know now that the animation property will run at least one cycle or as specified with the animation-iteration-count. a cycle with time set using animation-duration prpoerty(for example 2s or infinite).in our case here the animation will be 3 cycles of animation.that is runing the styles in the frames 3 times each cycle of will take 3 seconds to end at a speed rate of ease.note here that once the animation has finished and no cycles are left to be run again the animation property will end it's job and we are back to our element's styles defined before and after the animation property unless we specify animation-iteration-count property to be infinite.

The frames:

the frames will run the code inside it and therefore new styls and updeted styles will be added to the element as an animation.the frames 0%,25%...are points in the time specified for the animation and this is the reason we use css animation using @keyframes so that we can add styles or update styles at these points as much as we wish.

let's start the animation duration:

  1. Controling the frames:

  2. I need to keep in mind that when animating element(specialy with transform) i need to calculate the element size,the container size and how much space is left when the element is transformed.
  3. i can use timing-functions inside the frames to give that frame the speed i want.so,for instance if i assign a speed of ease-in for the frame 50%.that speed rate will be given for the intermediate values bettwen the 50% frame and the next frame.
  4. three iteration cycles means one cycle repeated three times.each time starting from the first keyframe to the last keyfrmae and then jumping to the normal state or whatever specified for the animation when it ends.infinite means one cycle being repeated forever.we could also say three cycles is one cycle being repeated only three times.
  5. using animation-direction: reverse values will reverse easing functions as well!.
  6. the delay is applied for the entire animation before it starts not for each cycle.to have the same effect but for each cycle.different approach is used.in the other hjand transitions use the delay time while traveling from normal state to new state and from new state to normal state.
  7. it's okay to use a specific timing-function on one of the frmaes along with the timing-function that is used inside the animation property.the timing-function used on one frame will affect only that frame duration.i can notice the difference here:
    only one timing-function used in animation property