Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Keyframe Animations and Syntax | Mastering Transforms and Animations
CSS Animations and Transitions

bookKeyframe Animations and Syntax

To create more dynamic and expressive effects than simple transitions allow, you can use the @keyframes rule to define CSS animations.

Keyframe animations let you describe a sequence of visual changes at specific points in time, rather than just animating between two states. The @keyframes syntax lets you specify the intermediate steps of an animation, while the animation property applies this sequence to an element and controls how it plays.

index.html

index.html

styles.css

styles.css

copy

In the bouncing ball example, the @keyframes rule defines the animation sequence named bounce. This sequence has three steps:

  • At 0% and 100%, the ball is at the top position (top: 0);
  • At 50%, it moves down to top: 80px.

The animation property on the .ball class applies the bounce keyframes, sets the duration to 1s, and makes the animation repeat infinitely.

By adjusting the keyframe steps, you control how the ball moves over time, and the animation property determines how quickly and how often the sequence plays.

question mark

Which of the following statements about the bouncing ball animation are true

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 2

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain how to create a custom keyframe animation?

What other properties can I use with the animation property?

How do I pause or stop a CSS animation?

Awesome!

Completion rate improved to 8.33

bookKeyframe Animations and Syntax

Swipe to show menu

To create more dynamic and expressive effects than simple transitions allow, you can use the @keyframes rule to define CSS animations.

Keyframe animations let you describe a sequence of visual changes at specific points in time, rather than just animating between two states. The @keyframes syntax lets you specify the intermediate steps of an animation, while the animation property applies this sequence to an element and controls how it plays.

index.html

index.html

styles.css

styles.css

copy

In the bouncing ball example, the @keyframes rule defines the animation sequence named bounce. This sequence has three steps:

  • At 0% and 100%, the ball is at the top position (top: 0);
  • At 50%, it moves down to top: 80px.

The animation property on the .ball class applies the bounce keyframes, sets the duration to 1s, and makes the animation repeat infinitely.

By adjusting the keyframe steps, you control how the ball moves over time, and the animation property determines how quickly and how often the sequence plays.

question mark

Which of the following statements about the bouncing ball animation are true

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 2
some-alt