Skip to content

Instantly share code, notes, and snippets.

@dziudek
Created August 4, 2012 21:24
Show Gist options
  • Save dziudek/3260056 to your computer and use it in GitHub Desktop.
Save dziudek/3260056 to your computer and use it in GitHub Desktop.
Animated circle
/**
* Animated circle
*/
#circle {
background: #f5a;
border-radius: 50%;
box-sizing: border-box;
height: 200px;
margin: 50px;
width: 200px;
}
#circle > div {
box-sizing: border-box;
float: left;
height: 100px;
overflow: hidden;
width: 100px;
}
#circle > div > div {
background: #fff;
height: 100px;
transform: rotate3d(0, 0, 1, 0deg);
width: 100px;
}
#circle > div:nth-child(1) > div { transform-origin: 100% 100%; }
#circle > div:nth-child(2) > div { transform-origin: 0% 100%; }
#circle > div:nth-child(3) > div { transform-origin: 100% 0%; }
#circle > div:nth-child(4) > div { transform-origin: 0% 0%; }
#circle:hover > div > div {
animation-name: spin;
animation-duration: 0.2s;
animation-iteration-count: 1;
animation-direction: alternate;
animation-fill-mode: both;
animation-timing-function: linear;
}
#circle:hover > div:nth-child(1) > div { animation-delay: 0s; }
#circle:hover > div:nth-child(2) > div { animation-delay: 0.2s; }
#circle:hover > div:nth-child(4) > div { animation-delay: 0.4s; }
#circle:hover > div:nth-child(3) > div { animation-delay: 0.6s; }
@keyframes spin {
from {
transform: rotate3d(0, 0, 1, 0deg);
}
to {
transform: rotate3d(0, 0, 1, 90deg);
}
}
<!-- content to be placed inside <body>…</body> -->
<div id="circle">
<div><div></div></div>
<div><div></div></div>
<div><div></div></div>
<div><div></div></div>
</div>
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment