JSFiddle - React, Tailwind, and code Playground
by Boban Stojanovski
HTML
<div id="brnx-loading" class="brnx-loading" onclick="endAnimation()"></div>
CSS
.brnx-loading {
position: fixed;
z-index: 9999;
height: 60px;
width: 60px;
overflow: show;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
/* visibility: hidden; */
}
/* Transparent Overlay */
.brnx-loading:before {
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
}
/* :not(:required) hides these rules from IE9 and below */
.brnx-loading:not(:required) {
/* hide "loading..." text */
font: 0/0 a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
.brnx-loading:not(:required):after {
height: 50px;
width: 50px;
margin-left: -25px;
content: '';
display: block;
-webkit-animation: rotation 1200ms infinite linear;
-moz-animation: rotation 1200ms infinite linear;
-ms-animation: rotation 1200ms infinite linear;
-o-animation: rotation 1200ms infinite linear;
animation: rotation 1200ms infinite linear;
border-left: 6px solid rgba(60, 167, 115, .15);
border-right: 6px solid rgba(60, 167, 115, .15);
border-bottom: 6px solid rgba(60, 167, 115, .15);
border-top: 6px solid rgba(60, 167, 115, .8);
border-radius: 100%;
}
/* Animation */
@-webkit-keyframes rotation {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
}
}
@-moz-keyframes rotation {
from {
-moz-transform: rotate(0deg);
}
to {
-moz-transform: rotate(359deg);
}
}
@-o-keyframes rotation {
from {
-o-transform: rotate(0deg);
}
to {
-o-transform: rotate(359deg);
}
}
@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
JavaScript
function endAnimation() {
var loader = document.getElementById("brnx-loading");
loader.style.visibility = "hidden";
}
function startNewAnimation() {
}