Last active
September 19, 2021 13:07
-
-
Save csssecrets/66e1e52ac2a44ad87aa4 to your computer and use it in GitHub Desktop.
Static pie charts
This file contains hidden or 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
| /** | |
| * Static pie charts | |
| */ | |
| .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: transparent; | |
| 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; | |
| } |
This file contains hidden or 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="pie">0%</div> | |
| <div class="pie">20%</div> | |
| <div class="pie">40%</div> | |
| <div class="pie">60%</div> | |
| <div class="pie">80%</div> |
This file contains hidden or 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
| function $$(selector, context) { | |
| context = context || document; | |
| var elements = context.querySelectorAll(selector); | |
| return Array.prototype.slice.call(elements); | |
| } | |
| $$('.pie').forEach(function(pie) { | |
| var p = pie.textContent; | |
| pie.style.animationDelay = '-' + parseFloat(p) + 's'; | |
| }); |
This file contains hidden or 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
| {"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