CSS @keyframes rule

It describes the rule of animation that depicts the properties of CSS for the components at every state along with the timeline.

We may make the properties of complex animation with the use of the @keyframe. The animation can be made with the varying styles of CSS that are repeated endlessly or the time’s finite number. A general animation may contain two keyframes, although a complex animation contains various keyframes.

Syntax:

To use the keyframes, we must create the @keyframe rule with the property animation-name to match the animation along with their keyframe declaration.

This property of CSS accepts the three values, which are discussed in detail, as given below:

Property Values

animation-name: This value is a required value, and it represents the animation name.

keyframes-selector: This value describes the percentage with an animation when any keyframe occurs. It has values that lie among 0%-100%, from (similarly as 0%), to (similarly as 100%). The percentage o keyframe can be defined in order because this percentage will be controlled in that order in which they occur.

css-styles:  This property value represents one or above than one property of CSS style.

If any keyframe rules do not define the end and start animation states, then any browser will apply the actual component’s styles. The properties can be ignored that will not be animated inside the keyframe rules.

Timing function of keyframes

To control the rule of animation, we may apply the values discussed as follows:

linear: It specifies the rate of the transition perceptual from start edge to end edge.

ease: It stipulates that animation will start gradually, and after a period of time, the speed will increase, and the speed of before end will slow down again.

ease-in: This function is the same as ease function, although an animation will end quickly.

ease-out: This function is also the same as the ease function, although an animation will start fast.

Let’s understand the @keyframe rule of CSS, along with the following examples.

Example:1

Output:

CSS @keyframes rule

Example:2

Output:

CSS @keyframes rule

Key Points:

There are some key points about the rule are discussed below:

  • We may apply from keyword rather than the use of 0%.
  • We may refer to the keyword rather than the use of 100%.
  • Even when we use from and to keywords, the values among them will be declared within 0%.
  • To a valid animation, the starting time and ending time should be declared.
  • These declarations will get avoided that concerns the !important.

Pin It on Pinterest

Share This