Skip to content

Instantly share code, notes, and snippets.

@LucasKauz
Created October 9, 2017 12:55
Show Gist options
  • Save LucasKauz/d0285deb0425dab27286692078fb2036 to your computer and use it in GitHub Desktop.
Save LucasKauz/d0285deb0425dab27286692078fb2036 to your computer and use it in GitHub Desktop.
Animated donut with stroke
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Donut circle</title>
<style>
/** Rotate the donut to meet the circle top center */
.donut {
transform: rotate(-89.9deg);
}
/** Initial state as 70% completed */
.donut circle {
transition: stroke-dasharray .3s;
stroke-dasharray: 70 30;
}
/** SAD :( When we hover it becomes 30% */
.donut:hover circle {
stroke-dasharray: 30 70;
}
</style>
</head>
<body>
<svg width="50" height="50" class="donut" >
<circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dashoffset="0"></circle>
</svg>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment