Skip to content

Instantly share code, notes, and snippets.

@gartnera
Forked from anonymous/dabblet.css
Last active January 30, 2016 00:23
Show Gist options
  • Save gartnera/06d07d37845fb3a232fa to your computer and use it in GitHub Desktop.
Save gartnera/06d07d37845fb3a232fa to your computer and use it in GitHub Desktop.
Static pie charts
/**
* Static pie charts
*/
span {
z-index:100;
position:fixed;
width: 115px;
left: 0;
text-align:center;
font-size: 20pt
}
.pie {
display: inline-block;
position: relative;
width: 100px;
line-height: 100px;
border-radius: 50%;
background: #655;
background-image: linear-gradient(to right, transparent 50%, yellowgreen 0);
color: black;
text-align: center;
}
@keyframes spin {
to { transform: rotate(.5turn); }
}
@keyframes bg {
50% { background: yellowgreen; }
}
.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="100" >&nbsp;<span>10<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