Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2016 23:59
Show Gist options
  • Save anonymous/e57d0632cfa52992029e to your computer and use it in GitHub Desktop.
Save anonymous/e57d0632cfa52992029e to your computer and use it in GitHub Desktop.
Static pie charts
/**
* Static pie charts
*/
span {
z-index:100;
position:fixed;
left:45px;
}
.pie {
display: inline-block;
position: relative;
width: 100px;
line-height: 100px;
border-radius: 50%;
background: yellowgreen;
background-image: linear-gradient(to right, transparent 50%, #655 0);
color: black;
text-align: center;
}
@keyframes spin {
to { transform: rotate(.5turn); }
}
@keyframes bg {
50% { background: #655; }
}
.pie::before {
content: '';
position: absolute;
top: 0; left: 50%;
width: 50%; height: 100%;
border-radius: 0 100% 100% 0 / 50%;
background-color: inherit;
transform-origin: left;
animation: spin 50s linear infinite, bg 100s step-end infinite;
animation-play-state: paused;
animation-delay: inherit;
}
.pie::after{
content: '';
top: 15px; left: 15px;
width: 70px; height: 70px;
position:absolute;
border-radius: 100%;
background-color: white;
}
<div class="pie" data-percent="10" ><span>100<span></div>
function $$(selector, context) {
context = context || document;
var elements = context.querySelectorAll(selector);
return Array.prototype.slice.call(elements);
}
$$('.pie').forEach(function(pie) {
var p = pie.dataset.percent;
pie.style.animationDelay = '-' + parseFloat(p) + 's';
});
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment