A modern svg spinner animarion in css
Created
September 25, 2017 00:33
-
-
Save groteck/547e4a5659a40a0afe70d4d7d1ce00b8 to your computer and use it in GitHub Desktop.
css svg spinner
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
<!-- | |
Follow me on | |
Dribbble: https://dribbble.com/supahfunk | |
Twitter: https://twitter.com/supahfunk | |
Codepen: https://codepen.io/supah/ | |
--> | |
<svg class="spinner" viewBox="0 0 200 200"> | |
<circle class="path" cx="100" cy="100" r="80" fill="none" stroke-width="20"></circle> | |
</svg> |
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
html, body { | |
height: 100%; | |
background-image: linear-gradient(-105deg, #009acc, #363795); | |
} | |
.spinner { | |
transform: rotate(90deg); | |
z-index: 2; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
margin: -25px 0 0 -25px; | |
width: 200px; | |
height: 200px; | |
& .path { | |
stroke: hsl(210, 70, 75); | |
stroke-linecap: round; | |
animation: dash 1s linear infinite; | |
} | |
} | |
@keyframes dash { | |
0% { | |
stroke-dasharray: 1, 600; | |
stroke-dashoffset: 0; | |
} | |
15% { | |
stroke-dasharray: 70, 600; | |
stroke-dashoffset: 0; | |
} | |
50% { | |
stroke-dasharray: 70, 600; | |
stroke-dashoffset: -140; | |
} | |
85% { | |
stroke-dasharray: 70, 600; | |
stroke-dashoffset: -396; | |
} | |
100% { | |
stroke-dasharray: 1, 600; | |
stroke-dashoffset: -496; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment