Simulation of positive cosine curve of CSS animation by example sharing

Source: Internet
Author: User
Write an animation of the CSS3 parabola today = =

From left to right parabolic animation, we will temporarily divide the motion into a uniform right motion and variable speed up and down movement.

Horizontal uniform Motion We can use TranslateX (x): Define 2D transformations, move elements along the x-axis, and linear: the speed of the animation from beginning to end is the same as the two attribute values to achieve;

The upper and lower variable motion can take advantage of Translatey (y): Define 2D transformations, move elements along the y axis, and ease-in-out: Animations start and end at low speed.

1.html

<div id= "Container" >      <div class= "Demobox" >           <div class= "Demo" ></div>      </div >      <div class= "Demobox" >            <div class= "Demo" ></div>      </div></div>

The Demobox p to the right of the uniform movement, the inside of the demo p do up and down the speed of movement.

2.css

#container {height:110px;    font-size:0; width:140px;}.    Demobox {float:right;    width:5px;    height:5px;    Animation:myfirst1 linear 5s Infinite; -webkit-animation:myfirst1 linear 5s Infinite;    }.demo {width:6px;    height:6px;    border-radius:3px;    Background: #90e4e9;    Animation:myfirst2 ease-in-out 1s infinite alternate;  -webkit-animation:myfirst2 ease-in-out 1s infinite alternate; /*safari and Chrome */}.demobox:nth-of-type (1). Demo:nth-of-type (1) {animation-delay:0s;}. Demobox:nth-of-type (2). Demo:nth-of-type (1) {animation-delay:0.03s;}        @keyframes myfirst1{from {transform:translatex (0px);    -webkit-transform:translatex (0px);        } to {Transform:translatex (1000px);    -webkit-transform:translatex (1000px);        }}@-webkit-keyframes myfirst1/* Safari and Chrome */{from {transform:translatex (0px);    -webkit-transform:translatex (0px);        } to {Transform:translatex (1000px); -webkit-transfOrm:translatex (1000px);        }} @keyframes myfirst2{0% {transform:translatey (0px);    -webkit-transform:translatey (0px);        } 50% {Transform:translatey (100px);    -webkit-transform:translatey (100px);        } 100% {transform:translatey (0px);    -webkit-transform:translatey (0px);        }}@-webkit-keyframes myfirst2/* Safari and Chrome */{0% {transform:translatey (0px);    -webkit-transform:translatey (0px);        } 50% {Transform:translatey (100px);    -webkit-transform:translatey (100px);        } 100% {transform:translatey (0px);    -webkit-transform:translatey (0px); }}

OK, a sine-cosine curve comes out @ ^-^ @

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.