Detailed selector bindings for @keyframes keyframe animations in CSS3

Source: Internet
Author: User
In CSS3, we can create keyframe animation effects through @keyframes. We need to bind the @keyframes to the selector, otherwise no effect will occur. Also, we need to define the animation duration and animation name

Grammar

@keyframes Animationname {keyframes-selector {css-styles;}}


value Description
Animationname Necessary. Defines the name of the animation.
Keyframes-selector Necessary. The percentage of the animation duration.


In CSS3, we specify the time for the change to occur as a percentage, or by the keyword "from" and "to", equivalent to 0% and 100%. Where 0% is the start time of the animation, and the end time of the 100% animation.

Keyframe Selector
Let's add some animation rules to @keyframes:

@keyframes Sunrise {      0% {         bottombottom:0;         left:340px;         Background: #f00;      }        33% {         bottombottom:340px;         left:340px;         Background: #ffd630;      }        66% {         bottombottom:340px;         left:40px;         Background: #ffd630;      }        100% {         bottombottom:0;         left:40px;         Background: #f00;      }   }

By adding these new animation rules, we introduced the keyframe selector. In the example code above, 0%, 33%, 66%, and 100% are the keyframe selectors. Of these, 0% and 100% can be replaced with "from" and "to".
The four sets of animation rules in the example express the four states of the animated element (four keyframes), and the styles that are in the four states. States that are not defined (for example, from 34% to 65%) make up the transition state between these defined states.
Although the specification is still being modified, some rules users should abide by it. For example, KeyFrames's writing order is not important, and they are played in ascending percentages. So, if you put the "to" keyframe before the "from" Keyframe, the animation won't change. In addition, if you do not specify a to or from or a corresponding percentage, the browser will automatically add. Therefore, the @keyframes syntax does not conform to the general CSS syntax of the cascading overlay rules.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.