Basic CSS Animation    
Tags: css, ui, html, css3
Published: 2020-04-21 10:59:09

---
title:Basic CSS Animation    
published: true
description: 
tags: CSS, UI, HTML, CSS3
---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r848sg7e7kk7bnwvygdx.gif)


CSS animation is a proposed module for Cascading Style Sheets that allows designers and developers to add animations by editing the CSS code of their websites, instead of uploading GIF or flash images directly. With CSS animation, you can animate certain HTML elements without having to use processor and memory-hungry JavaScript or Flash. 
Animations consist of two components, a style describing the CSS animation and a set of keyframes that indicate the start and end states of the animation’s style, as well as possible intermediate waypoints.
To create a CSS animation sequence, you style the element you want to animate with the animation property or its sub-properties. 
The animation properties applies an animation between styles. The animation property is a shorthand property for:
 <code>animation-name</code>, <code>animation-duration</code>, <code>animation-timing-function</code>,<code>animation-delay</code>, <code>animation-iteration-count</code>, <code>animation-direction</code>,<code>animation-fill-mode</code>, and <code>animation-play-state</code>.
There's relationship between animation and <code>@keyframes </code>. Animation is a CSS property and to apply animation on the element which we create, we use <code>@keyframes</code>.
The <code>@keyframes</code> at-rule specifies the animation code.
The animation is created by gradually changing from one set of CSS styles to another.
This lets you configure the timing, duration, and other details of how the animation sequence should progress. This does not configure the actual appearance of the animation, which is done using the <code>@keyframes</code> at-rule as described in Defining the animation sequence using <code>@keyframes</code>.
The animation-name property is used to specify one or more names of animations defined by <code> @keyframes</code> at-rules, that are to be applied to the selected element.
A <code>@keyframes</code> at-rule specifies the property values that are to be animated over a sequence of animation keyframes.
You can specify either one animation name in animation-name or a list of comma-separated names. Each name belongs to a <code>@keyframes</code> identifier. If the animation name specified using animation-name does not exist, no animation is applied.
The <code>@keyframes</code> rule specifies the animation code and it describes how the animated element should render at a given time during the animation sequence.
The CSS transform property is also used to alter the original form of an element. To do this, we can scale, rotate, skew, or translate the element. This can be achieved using the 2D or 3D transform property functions. The transform CSS property specifies a handful of transformation functions that can be combined any way you wish: <code>scale()</code>,<code> skew()</code>,<code>translate()</code>,<code>rotate()</code> and <code>matrix()</code>.
1. scale(width, height): the scale function is used to alter the size of the element. The default value is 1. Values below 1 scales element down and values above 1 scales element up. Specifying only one value means that both width and height will be proportionately scaled.
2. skew(x, y): the skew function is used to distort an element along the horizontal axis(x-value). Or along the vertical axis(y-value), or on both axis.
3. translate(x, y): the translate function is used to move an element along the x-axis or the y-axis. It works like a relatively positioned element.
4. rotate(deg): the rotate function is used to rotate an element either clockwise or anti-clockwise. Element rotates clockwise between 0-360 degrees or anti-clockwise if the rotate value is negative.
5. matrix(): the matrix function is used to combine all the 2D transform functions together.

CSS Animations are great for animations that are relatively simple, because of the way<code>@keyframes</code>is structured. If you want to create a more complex animation, I will recommend you use Javascript to create your animation instead.
That’s it! With those basic properties, the possible animations you can create are endless.

Here is a resource file to get you started:
 
[CodePen] (https://codepen.io/iamdejean/pen/abvzoXg)-The flying birds