CSS style animations

Source: Internet
Author: User

1. When in @keyframesCreate an animation, bind it to a selector, or the animation will have no effect.

Specifies that at least these two CSS3 animated properties are bound to a selector:

    • Specify the name of the animation
    • Specify the duration of the animation

Div {

             animation: myfirst 5s

-webkit-animation: myfirst 5s; /* Safari with Chrome * /

}

2. Animations are effects that gradually change an element from one style to another.

You can change any number of styles any number of times.

Use percentages to specify when changes occur, or use the words "from" and "to", equivalent to 0% and 100%.

0% is the beginning of the animation, and 100% is the completion of the animation.

For best browser support, you should always define the 0% and 100% selectors.

Example:

Change the background color when the animation is 25% and 50%, then change it again when animation 100% finishes

@keyframes myfirst {

0% {background: red;}

< Span class= "Hl-var" >            25% {background: yellow /span>

< Span class= "Hl-var" > < Span class= "hl-reserved" >           50% {background: blue;}

< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp         100% {background: green;}

}

< Span class= "Hl-code" > < Span class= "hl-brackets" > @-webkit-keyframes myfirst /* safari and Chrome */

< Span class= "Hl-code" >          { 0% {background:< Span class= "Hl-code" > red;

< Span class= "hl-brackets" >          25% {background:  yellow;"

< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp        50% {background: blue;}

< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp        100% {background: green;}

}

@keyframes: Specify animation

Animation: short for all animated properties

Animation-name: Animated Name

CSS style animations

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.