css3 - CSS transform to rotate an element in an oval path -



css3 - CSS transform to rotate an element in an oval path -

i have jsfiddle here - http://jsfiddle.net/w23v50h5/1/

div { position: absolute; left: 315px; top: 143px; width: 50px; height: 50px; background: red; -webkit-animation: myorbit 6s linear infinite; -moz-animation: myorbit 6s linear infinite; -o-animation: myorbit 6s linear infinite; animation: myorbit 6s linear infinite; } @-webkit-keyframes myorbit { { -webkit-transform: rotate(0deg) translatex(5px) translatey(120px) rotate(0deg);} { -webkit-transform: rotate(360deg) translatex(5px) translatey(120px) rotate(-360deg); } } @-moz-keyframes myorbit { { -moz-transform: rotate(0deg) translatex(100px) rotate(0deg); } { -moz-transform: rotate(360deg) translatex(100px) rotate(-360deg); } } @-o-keyframes myorbit { { -o-transform: rotate(0deg) translatex(100px) rotate(0deg); } { -o-transform: rotate(360deg) translatex(100px) rotate(-360deg); } } @keyframes myorbit { { transform: rotate(0deg) translatex(100px) rotate(0deg); } { transform: rotate(360deg) translatex(100px) rotate(-360deg); } }

i'm using css trasform move element in oval shape.

i'd path element moving on flatter oval shape.

i scale element it's smaller @ top of oval , larger @ bottom gives impression of oval orbit going backwards , coming forwards.

can help create orbit flatter , scale element.

you can utilize % instead "from to" in animation this:

0% { -webkit-transform: rotate(0deg) translatex(5px) translatey(120px) rotate(0deg) scale(1); } 25% { -webkit-transform: rotate(90deg) translatex(5px) translatey(120px) rotate(-90deg) scale(.75); } 50% { -webkit-transform: rotate(180deg) translatex(5px) translatey(120px) rotate(-180deg) scale(.60); } 75% { -webkit-transform: rotate(270deg) translatex(5px) translatey(120px) rotate(-270deg) scale(.75); } 100% { -webkit-transform: rotate(360deg) translatex(5px) translatey(120px) rotate(-360deg) scale(1); }

a jsfiddle implementation: http://jsfiddle.net/jutmlgud/

css css3 css-animations css-shapes css-transforms

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -