Skip to content

Instantly share code, notes, and snippets.

Created January 20, 2014 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8516429 to your computer and use it in GitHub Desktop.
Save anonymous/8516429 to your computer and use it in GitHub Desktop.
A Pen by A Non Ymous.

An Anonymous Pen

Recreated http://imgur.com/GqdaY5F in one element. I don't take credit for the original (nor do I know where it's from)

There are some pretty cool tricks I came up with in order to do so:

All of the big rings are done using box shadows, as are three of the small circles

One of the small circles is done using :before, the other rotating counter clockwise is :before's box shadow

To allow the second two small circles to go in the opposite direction, a translateY was needed before and after the rotate, for more information on the approach go here http://www.useragentman.com/blog/2013/03/03/animating-circular-paths-using-css3-transitions/ (I play with it a bit to fit my case)

I used an SVG as a background URL in the :after pseudoelement to get the segmented circle

I would optimize the paint time by increasing the animation duration and rotation degree by the same factor, but the white flashes make that far more difficult. I would have to calculate new %s when the dots overlap and have to add those to the list... Maybe one day...

A Pen by Anonasaurus Rex on CodePen.

License.

<div id='gif'></div>
// Check out more of my projects here or at http://zachsaucier.com/
body { background:black; overflow:hidden; }
#gif {
background:black;
padding:10px;
height:80px;
width:80px;
border-radius:50%;
position:absolute;
top:calc(50% - 40px);
left:calc(50% - 40px);
box-shadow:
178px 0 0 -25px black,
178px 0 0 -20px white,
-178px 0 0 -25px black,
-178px 0 0 -20px white,
0 0 0 20px black,
0 0 0 30px white,
0 0 0 130px black,
0 0 0 135px white;
-webkit-animation: rotate 3s linear infinite;
animation: rotate 3s linear infinite;
}
#gif:before {
content: " ";
position: absolute;
height:50px;
width:50px;
border-radius:50%;
top: -155px;
left: 20px;
background:black;
border: 5px solid white;
box-shadow:
0 355px 0 -5px black,
0 355px 0 0px white;
-webkit-animation: reverseRotate 3s linear infinite;
animation: reverseRotate 3s linear infinite;
}
#gif:after {
/* Segmented circle code goes here */
content: " ";
position: absolute;
height:280px;
width:280px;
left:-90px;
top:-90px;
background-image: url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSAiaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmlld0JveD0iMCAwIDEwMCAxMDAiID4NCiAgICA8Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI0MCIgc3Ryb2tlLWRhc2hhcnJheT0iMC45NTIiIHN0cm9rZS13aWR0aD0iOCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJ3aGl0ZSIvPg0KPC9zdmc+");
background-repeat: no-repeat;
z-index:2;
-webkit-animation: segmentRotate 300s linear infinite;
animation: segmentRotate 300s linear infinite;
}
@keyframes rotate {
0% { transform: rotate( 0deg); }
10%, 15%, 35%, 40%, 60%, 65%, 85%, 90% {
background: black;
box-shadow:
178px 0 0 -25px black,
178px 0 0 -20px white,
-178px 0 0 -25px black,
-178px 0 0 -20px white,
0 0 0 20px black,
0 0 0 30px white,
0 0 0 130px black,
0 0 0 135px white;
}
12.5%, 37.5%, 62.5%, 87.5% {
background: white;
box-shadow:
178px 0 0 -25px white,
178px 0 0 -20px white,
-178px 0 0 -25px white,
-178px 0 0 -20px white,
0 0 0 20px black,
0 0 0 30px white,
0 0 0 130px black,
0 0 0 135px white;
}
100% { transform: rotate(360deg); }
}
@keyframes reverseRotate {
0% { transform: translateY(178px) rotate(0deg) translateY(-178px) rotate(0deg); }
10%, 15%, 35%, 40%, 60%, 65%, 85%, 90% {
background: black; box-shadow: 0 355px 0 -5px black, 0 355px 0 0px white;
}
12.5%, 37.5%, 62.5%, 87.5% {
background: white; box-shadow: 0 355px 0 -5px white, 0 355px 0 0px white;
}
100% { transform: translateY(178px) rotate(-720deg) translateY(-178px) rotate(0deg); }
}
@keyframes segmentRotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(-32000deg); }
}
@-webkit-keyframes rotate {
0% { -webkit-transform: rotate( 0deg); }
10%, 15%, 35%, 40%, 60%, 65%, 85%, 90% {
background: black;
box-shadow:
178px 0 0 -25px black,
178px 0 0 -20px white,
-178px 0 0 -25px black,
-178px 0 0 -20px white,
0 0 0 20px black,
0 0 0 30px white,
0 0 0 130px black,
0 0 0 135px white;
}
12.5%, 37.5%, 62.5%, 87.5% {
background: white;
box-shadow:
178px 0 0 -25px white,
178px 0 0 -20px white,
-178px 0 0 -25px white,
-178px 0 0 -20px white,
0 0 0 20px black,
0 0 0 30px white,
0 0 0 130px black,
0 0 0 135px white;
}
100% { -webkit-transform: rotate(360deg); }
}
@-webkit-keyframes reverseRotate {
0% { -webkit-transform: translateY(178px) rotate(0deg) translateY(-178px) rotate(0deg); }
10%, 15%, 35%, 40%, 60%, 65%, 85%, 90% {
background: black; box-shadow: 0 355px 0 -5px black, 0 355px 0 0px white;
}
12.5%, 37.5%, 62.5%, 87.5% {
background: white; box-shadow: 0 355px 0 -5px white, 0 355px 0 0px white;
}
100% { -webkit-transform: translateY(178px) rotate(-720deg) translateY(-178px) rotate(0deg); }
}
@-webkit-keyframes segmentRotate {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(-32000deg); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment