Skip to content

Instantly share code, notes, and snippets.

@20manas
Created November 9, 2023 17:34
Show Gist options
  • Save 20manas/48a751f89c5ddbd3b77f9e6cfce6b324 to your computer and use it in GitHub Desktop.
Save 20manas/48a751f89c5ddbd3b77f9e6cfce6b324 to your computer and use it in GitHub Desktop.
Spinner
@keyframes rotateAndClip {
0% {
clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 0, 100% 0, 100% 0);
}
17% {
clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);
}
33% {
clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 100%);
}
50% {
clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 0);
}
58% {
clip-path: polygon(50% 50%, 100% 0, 100% 0, 100% 100%, 0 100%, 0 0);
}
75% {
clip-path: polygon(50% 50%, 100% 100%, 100% 100%, 100% 100%, 0 100%, 0 0);
}
92% {
clip-path: polygon(50% 50%, 0 100%, 0 100%, 0 100%, 0 100%, 0 0);
}
100% {
clip-path: polygon(50% 50%, 0 50%, 0 50%, 0 50%, 0 50%, 0 0);
rotate: 450deg;
}
}
.spinner {
--size: 24px;
--border-color: violet;
border-radius: 50%;
width: var(--size);
height: var(--size);
border-style: solid;
border-width: calc(var(--size) / 6);
border-color: var(--border-color);
clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 0, 100% 0, 100% 0);
animation: rotateAndClip 2s linear infinite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment