Skip to Content
Practical Web Design
book

Practical Web Design

by Philippe Hong
April 2018
Beginner content levelBeginner
368 pages
7h 37m
English
Packt Publishing
Content preview from Practical Web Design

CSS animation

CSS animation allows for the creation of animation without JS or Flash, with keyframes and every CSS property. It offers more advantages than a simple transition. 

To create a CSS animation, you need to create a keyframe:

/* The animation code */@keyframes example {    from {background-color: red;}    to {background-color: yellow;}}

from means at the start of the animation, while to means at the end of the animation.

You can also be more precise with the timeframe by setting the percentage: 

/* The animation code */@keyframes example {    0% {background-color: red;}    25% {background-color: yellow;}    50% {background-color: blue;}    100% {background-color: green;}}

To trigger the animation, you need to call it in the specific div with the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Design Playground

Web Design Playground

Paul McFedries
Hello Web Design

Hello Web Design

Tracy Osborn
The Principles of Beautiful Web Design, 4th Edition

The Principles of Beautiful Web Design, 4th Edition

Jason Beaird, Alex Walker, James George

Publisher Resources

ISBN: 9781788395038Supplemental Content