throbber animation
by Alexandru Gatea
HTML
<div id="throbber"></div>
<div class="throbber"></div>
SCSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-image: url('https://www.seedinvest.com/wp-content/uploads/2014/12/1600x1200-new-york-city-skyline-wallpaper-black-and-white.jpg');
background-color: #212121;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
height: 100vh;
background-blend-mode: multiply;
}
#throbber,
.throbber {
display: block;
width: 150px;
height: 150px;
border-radius: 50%;
position: fixed;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
background: transparent;
border: 10px solid transparent;
background-blend-mode: multiply;
&:before,
&:after {
position: absolute;
content: "";
width: 70%;
height: 70%;
border-radius: 50%;
border: 10px solid;
left: 50%;
}
}
#throbber {
animation: rotate 6s linear infinite;
&:before {
top: 0;
transform: translate(-50%, -50%);
background: rgba(198, 40, 40, 0.3);
border-color: rgba(198, 40, 40, 0.5);
animation: toBottom 3s ease-in-out infinite;
}
&:after {
bottom: 0;
transform: translate(-50%, 50%);
background: rgba(255, 143, 0, 0.3);
border-color: rgba(255, 143, 0, 0.5);
animation: toTop 3s ease-in-out infinite;
}
}
.throbber {
animation: rotate 6s linear infinite;
&:before,
&:after {
top: 50%;
transform: translateY(-50%);
}
&:before {
left: 0;
top: 50%;
transform: translate(-50%, -50%);
background: rgba(2, 119, 189, 0.3);
border-color: rgba(2, 119, 189, 0.5);
animation: toRight 3s ease-in-out infinite;
}
&:after {
right: 0;
left: auto;
background: rgba(85, 139, 47, 0.3);
border-color: rgba(85, 139, 47, 0.5);
transform: translate(50%, -50%);
animation: toLeft 3s ease-in-out infinite;
}
}
@keyframes toBottom {
0% {
top: 0;
}
50% {
top: 100%
}
}
@keyframes toTop {
0% {
bottom: 0;
}
50% {
bottom: 100%;
...