JSFiddle - React, Tailwind, and code Playground
by Henry
HTML
<div class="spinner"></div>
SCSS
body {
background: #000;
}
.spinner {
position: absolute;
top: 50%;
left: 50%;
z-index: 2;
transform: translate3d(-50%, -50%, 0);
&::before {
//&::after {
position: absolute;
top: -20px;
left: -20px;
// transform: translate3d(-50%, -50%, 0);
content: '';
display: block;
box-sizing: border-box;
width: 40px;
height: 40px;
border-radius: 100%;
border: 5px solid rgba(255, 255, 255, 0.2);
// border-top-color: rgba(255, 255, 255, 0.5);
animation: spin1 1s infinite linear, border 5s infinite alternate, border-top 3s infinite linear;
}
/* &::after {
animation: spin1 2s infinite linear, border 9s infinite linear reverse, border-top 7s infinite linear;
} */
}
@keyframes spin1 {
100% {
transform: rotate(360deg);
}
}
@keyframes spin2 {
100% {
transform: rotate(-360deg);
}
}
@keyframes border {
0% {
border-color: rgba(255,50,50,.2)
}
25% {
border-color: rgba(255,255,50,.2)
}
50% {
border-color: rgba(50,255,50,.2)
}
75% {
border-color: rgba(50,255,255,.2)
}
100% {
border-color: rgba(50,50,255,.2)
}
}
@keyframes border-top {
0% {
border-top-color: #ff0000
}
25% {
border-top-color: #00ff00
}
50% {
border-top-color: #0000ff
}
75% {
border-top-color: #00ff00
}
100% {
border-top-color: #ff0000
}
}