Languages
[Edit]
EN

CSS - keyframes animations

0 points
Created by:
Welsh
902

In this article, we would like to show you how to use @keyframes to create animations in CSS.

Introduction

Edit

The @keyframes rule controls the subsequent stages of CSS animation, defining the styles of keyframes (or subsequent points) during the duration of the animation.

Syntax

Edit

To create keyframes animation with given animation-name, we use the following syntax:

or we can use it with any percentage values from 0% to 100%:

Assigning animation to HTML element

Edit

To assign the animation to the element, we need to specify the CSS selector (e.g .element class) and add animation property to it with specified animation-name and animation-duration time.

Where:

  • animation-name is - the name of our animation (e..g fadein),
  •  animation-duration is the time during which our animation will be performed (e.g. 2s).

Note:

There are more animation configuration options to specify, but in order for animation to work, these two needs to be specified.

Practical example

Edit

In this example, we create fadein animation that goes from opacity: 0 to opacity: 1 making the element visible over specified time (2s).

 

See also

Edit
  1. CSS - fade in effect

  2. CSS - fade out effect

References

Edit
  1. @keyframes - CSS: Cascading Style Sheets | MDN
  2. Using CSS animations - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - @keyframes animations
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join