Circular motion trajectory of CSS3 animation

Source: Internet
Author: User

CSS3 The animation through @keyframes definition animation, animation set animation properties, so as to achieve the animated effect;

In the animation attribute, you can specify the name of the animation, the running time of the entire animation, the speed curve of the motion, and its delay time, number of plays, and so on.

Animation

Animation, as a composite property, includes the following animation properties.

    • Animation-name-------------------------------------Specify the name of the animation
    • Animation-duration---------------------------------Specify the time that the animation finishes once
    • Animation-timing-function----------------------The motion velocity curve of the specified animation
    • Animation-delay------------------------------------Specify the delay time of the animation
    • Animation-iteration-count-----------------------Specify the number of times the animation plays
    • Animation-direction------------------------------Specify whether the next cycle of animation starts in reverse
    • Animation-fill-mode-------------------------------states outside the animation time
    • Animation-play-state------------------------------Specify the animation to run and pause
Animation-timing-function

Specifies the speed curve of the animation. The default is "ease". The following are some of the most commonly used motion velocity curves:

    • Linear: Linear transition.
    • Ease-in: from slow to fast.
    • Ease-out: From fast to slow.
    • Ease-in-out: From slow to fast to slow.

You can also directly use the speed curve specified by the Bezier curve, and the 4 values of the Bezier curve must be within the [0, 1] interval.

Animation-direction

Specifies whether the animation will play backwards in the next cycle. The default is "normal".

    • Reverse: Opposite direction movement
    • Alternate: The normal direction and then the opposite direction of movement, continuous alternating
    • Alternate-reverse: Moving in the opposite direction again in the normal direction, continuously alternating
Animation-fill-mode

Specifies the state outside the object's animation time. Common values are as follows:

    • None: Default value
    • Forwards: Sets the state of the object at the end of the animation
    • Backwards: Sets the state of the object when the animation starts
Circular motion Trajectory

The implementation code is as follows:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Moving along a circular trajectory</title>    <styletype= "Text/css">        *{margin:0;padding:0;        }Html,body{Height:100%;        }#trajectory{width:300px;Height:300px;Border:4px Solid #949494;Border-radius:50%;position:relative; Left:Calc (50%-153px);Top:Calc (50%-153px);        }@keyframes MoveX{0% { left:-22px;}100%{ Left:282px;}} @keyframes Movey{0% {Top:-22px;}100%{Top:282px;}} #move{width:40px;Height:40px;font-size:12px;Background-color:#32c33a;Border-radius:50%;position:Absolute; Left:-22px;Top:-22px;Animation:moveX 4s cubic-bezier (0.36,0,0.64,1) -2s infinite Alternate, movey 4s cubic-bezier (0.36,0,0.64,1) 0s infinite alterna Te;        }    </style></Head><Body>    <DivID= "trajectory">        <DivID= "Move">Immortal Brother</Div>    </Div></Body></HTML>

The following points are noted in the code above:

    • The body height 100% is set due to the body's default height of 0 in the HTML5 environment
    • The spaces between the "-" and "+" between values and values are essential during the use of Calc
    • The left and top values in the animation are the starting and ending positions of the object motion, and note the border value
    • Only half the motion of the animation is executed at once
    • Speed curve: Cubic-bezier (0.36,0,0.64,1);
    • Two-direction delay time setting x:-2s; y:0s
    • The first positive direction and then the opposite direction continuously alternately runs: alternate

Circular motion trajectory of CSS3 animation

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.