Well... the title says it all! And yes it's done in CSS.
Created
January 12, 2014 04:34
-
-
Save naveenmaurya/8380978 to your computer and use it in GitHub Desktop.
A Pen by Naveen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="circle"></div> | |
<!-- | |
The red ball CSS has been taken from pen by Iván Suro (http://codepen.io/isuro/) | |
http://codepen.io/isuro/pen/LyCIo | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.circle { | |
display: block; | |
width: 100px; | |
height: 100px; | |
background: red; | |
border-radius: 50%; | |
background: -webkit-radial-gradient(25px 25px, circle, red, #000); | |
background: -moz-radial-gradient(25px 25px, circle, red, #000); | |
background: radial-gradient(25px 25px, circle, red, #000); | |
/* Animation to spin and move the sphere */ | |
-webkit-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite; | |
-moz-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite; | |
-ms-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite; | |
animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite; | |
-webkit-transition: all 1s ease; | |
transition: all 1s ease; | |
position: absolute; | |
left: 0; | |
} | |
/* Spinning the sphere using key frames */ | |
@-ms-keyframes spin { | |
from { -ms-transform: rotate(0deg); } | |
to { -ms-transform: rotate(360deg); } | |
} | |
@-moz-keyframes spin { | |
from { -moz-transform: rotate(0deg); } | |
to { -moz-transform: rotate(360deg); } | |
} | |
@keyframes spin { | |
from { transform: rotate(0deg); } | |
to { transform: rotate(360deg); } | |
} | |
@-webkit-keyframes spin { | |
from { -webkit-transform: rotate(0deg); } | |
to { -webkit-transform: rotate(360deg); } | |
} | |
/* Move sphere from left to right */ | |
@-moz-keyframes moveLeftToRight { | |
0% { left: -100px; } | |
100% { left: 100%; } | |
} | |
@-ms-keyframes moveLeftToRight { | |
0% { left: -100px; } | |
100% { left: 100%; } | |
} | |
@keyframes moveLeftToRight { | |
0% { left: -100px; } | |
100% { left: 100%; } | |
} | |
@-webkit-keyframes moveLeftToRight { | |
0% { left: -100px; } | |
100% { left: 100%; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment