

CSS Animations make animating web UI elements simple. You can achieve many animations without needing any JS or external packages and can be done straight away with vanilla CSS.
Let's break down CSS animations.



All CSS animations start with defining keyframes, before an element can be animated we need to define what the animation will be.
This is done using keyframes with either percentages or from/to.
2/14

Once we have our animation defined we can apply it to an element in one of two ways:


We'll come back to the shorthand syntax later, first let's look at all the properties.
3/14

This property declares the name of keyframe we are going to apply to the element.
See the previous tweet for an example.
Read More:

4/14

This property declares the length of time in either seconds or milliseconds to complete one cycle of the animation.
E.G.
animation-duration: 500ms;
animation-duration: 5s;
Read more:

5/14

This property establishes the acceleration curve for the animation to use.
E.G.
animation-timing-function: ease-in;
animation-timing-function: linear;
See a full list:

6/14

As the name suggests this property allows you to add delay to the start of the animation.
By default, animations will start immediately but this property allows you to change that.
E.G.
animation-delay: 1s;
Read More:

7/14

Allows you to state if the animation will play in reverse, normally or change on each run (alternate).
E.G.
animation-direction: alternate;
Read More:

8/14

This property allows you to specify how many times the animation should run or can be infinite if you don't want it to stop.
E.G.
animation-iteration-count: infinite;
animation-iteration-count: 5;
Read More:

9/14

This property controls the styles that apply to the element after the animation is finished.
If you animate an element to grow this controls if it stays grown after or not.
E.G.
animation-fill-mode: both;
Read More:

10/14

Controls the current play status of the animation. Can be toggled between play and pause.
E.G.
animation-play-state: running;
animation-play-state: paused;
Read More:

11/14

Animation shorthand syntax can control all of the above properties in one.
E.G.
animation: 3s ease-in 1s infinite reverse both running <NAME>;
or
duration | easing-function | delay | iteration-count | direction | fill-mode | play-state | name
12/14

Below are 2 resources that are extremely helpful for understanding animations and it's properties.
The CSS Tricks Article also contains a good CodePen you can play around on.
CSS Tricks Article: https://css-tricks.com/almanac/properties/a/animation/
MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations
13/14

If you found this thread on CSS Animations helpful, please consider liking and re-tweeting it so others can find it helpful too.
If you would like to see more content like this on your timeline please make sure to follow me.

14/14