How to conveniently control CSS3 animation start point and duration

Source: Internet
Author: User

In general, we can reduce the amount of code by shorthand to control CSS3 animate animations, as long as the class name is appended to the element that needs animation, as in the following example

/* fade in and move up a little position appears */.fadeinup{    -webkit-animation:fadeinup 1000ms. 8s ease both;}
@-webkit-keyframes Fadeinup {0% {opacity:0;-webkit-transform:translatey (20px); Transform:translatey (20px)}100% { Opacity:1;-webkit-transform:translatey (0); Transform:translatey (0)}}
This is a relatively streamlined layout compared to the previous. But when there are many elements in a page that run CSS3 animations, what's even worse is that most of the animations are the same type, but the points of motion are different from the duration of the time. In order to control the effect of the different elements of the start point of time has been the length of time, only copy and then copy, and then adjust the time and duration of the motion as needed. Like this:
. fadeinup01{    -webkit-animation:fadeinup 1200ms. 1s ease both;}. fadeinup03{    -webkit-animation:fadeinup 1400ms 1.2s ease both;}. fadeinup04{    -webkit-animation:fadeinup 1600ms 1.4s ease both;} ...

This keeps copying down .....

Would it be nice if we could separate the start time and duration of the animation from individual controls?

So we think of JS

Set the custom property $ (") for each animated element that appends the Cusanimatedom class name        . Cusanimatedom "). each (function () {            var _delay = $ (this). attr (" Data-delay ");            var _duration = $ (this). attr ("Data-duration");            $ (this). CSS ("-webkit-animation-delay", (_delay) + "MS");            $ (this). CSS ("-webkit-animation-duration", (_duration) + "MS");        });

See http://gift.guzhongyi.com/to see the source code can be more profound understanding, understanding.

How to conveniently control CSS3 animation start point and duration

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.