CSS3 two ways to implement animations

Source: Internet
Author: User

1, set transition settings transition, add transform set shape, animation effect, as follows:

. divadd {transition:all 0.4s ease-in-out;         -webkit-transition:all 0.4s ease-in-out;         -moz-transition:all 0.4s ease-in-out;         -o-transition:all 0.4s ease-in-out; Transform:rotate (360deg);-ms-transform:rotate (360deg); /* IE 9 */-webkit-transform:rotate (360deg); /* Safari and Chrome */}

This kind of way is relatively small, not easy to control

2, add the animation property, set the animation effect, as follows:

. A1 {position:absolute;animation:a1 3s;opacity:0} @keyframes A1 {0% {left:10px;opacity:0}30% {Left:60px;background-co lor:pink;font-size:23px;opacity:1}90% {left:100px;background-color:red;opacity:1}100% {left:10px;opacity:0}}

 

Various attribute values can be added within square brackets after the above percentages, such as transform Ratote, left ... Add left top and other positioning don't forget to set position absolute.

All properties are:

    Animation-name:myfirst;  Animated name, used for animation reference    animation-duration:5s;  Animation duration,    animation-timing-function:linear;    animation-delay:2s;    Animation-iteration-count:infinite;    Animation-direction:alternate;    animation-play-state:running;
Animation-fill-mode
Set the state after the animation has ended
None: Default value. Do not set state outside of object animation, Dom does not animate before state
Forwards: Sets the state of the object to the end of the animation, 100% or to when the animation ends when the animation-direcdtion is set to reverse the first frame of the keyframes
Backwards: Sets the state of the object at the start of the animation (test shows that the DOM is not animated before the state)
Both: Sets the state of the object to the end or start of the animation, and the end state takes precedence


CSS3 two ways to implement 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.