Ali Cope

Lesson 8 -Creating CSS3 Transitions and Animations in CSS and triggering them with JavaScript

CSS transitions create a way to control the speed that CSS properties change. This allows us to change things over time instead of having changes take place instantly.

We can trigger these transitions using a JavaScript button just like we did in the last lesson by adding classes. Here is what the CSS looks like for transitions.

transition CSS code

WOW! This is fun!


Animations

Animations use "keyframes" to specify what styles each element will have at which time. We can also add loops to have the animation run over again. On the first animation we have it set to run 3 times, on the second we want it to alternate forward and backward infinitly. The only way to stop the animation would be to click the button again, to remove the class we added. This is what the CSS code looks like for the animation. It is written in two different styles, both using @keyframe.

Animation Text

small cat