Web Animation Using CSS
Animation on the web is a big topic for web design and development. Starting from this post, I will start a series of writings devoted to the animation on the web. Animation can make the web page dynamic, attracting, beautiful and holding more customers. Animation is also a key factor for web based game design and development. Different techniques can be used to make animations. In this post, I explain how to make animations using CSS.
We all know the :hover
pseudo-class produces a state-change effect for HTML element. However, It is not actually animations. There is no duration between the state-change. CSS transition is the CSS property to add the duration needed for animation. Besides, CSS3 also provides transform
, keyframes
and animation
properties.
- CSS transition:
There are four CSS transition properties available, transition-property
, transition-duration
, transition-timing-function
and transition-delay
. They can also be abbreviated to a single transition
property. More transition-timing-function cubic-bezier
values can be found in cubicbezier website.
- CSS transform:
CSS transform is a css property to change the state of the HTML element. There are four different values for this property: translate(x, y)
, rotate(xdeg)
, skew(xdeg)
, scale(x, y)
.
- CSS keyframes:
Any animation is just a series of keyframes. CSS3 provides the @keyframes
rule to define different intermediate stages of animation keyframes.
- CSS media queries:
Media queries are originally designed for responsive web design and are still being used for this purpose. By thinking the way how media query works, animations can be designed when the web page’s size is being constantly adjusted, though it is not strictly an animation by definition.
These are just basic ways to make animations using CSS.