Skip to content

Instantly share code, notes, and snippets.

@priyanshujain
Last active August 14, 2020 19:13
Show Gist options
  • Save priyanshujain/43f6d66ac0c7e18810481485f31c4b52 to your computer and use it in GitHub Desktop.
Save priyanshujain/43f6d66ac0c7e18810481485f31c4b52 to your computer and use it in GitHub Desktop.
CSS loaders with gradient
.loader {
background: linear-gradient(to right, #2f54eb 10%, rgba(255, 255, 255, 0) 80%);
/* Show only 10px from the border */
-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 10px),#fff 0);
width: 150px;
height: 150px;
border-radius: 50%;
position: fixed;
top: calc(50% - 50px);
left: calc(50% - 50px);
animation: rotate 1s linear infinite;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% { transform: rotate(360deg); }
}
.loader {
font-size: 20px;
margin: 50px auto;
text-indent: -9999em;
width: 11em;
height: 11em;
border-radius: 50%;
background: #2f54eb;
background: -moz-linear-gradient(left, #2f54eb 10%, rgba(255, 255, 255, 0) 42%);
background: -webkit-linear-gradient(left, #2f54eb 10%, rgba(255, 255, 255, 0) 42%);
background: -o-linear-gradient(left, #2f54eb 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, #2f54eb 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, #2f54eb 10%, rgba(255, 255, 255, 0) 42%);
-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 10px),#fff 0);
position: relative;
-webkit-animation: load3 1.4s infinite linear;
animation: load3 1.4s infinite linear;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.loader:before {
width: 50%;
height: 50%;
background: #2f54eb;
border-radius: 100% 0 0 0;
position: absolute;
top: 0;
left: 0;
content: '';
}
.loader:after {
background: #fff;
width: 90%;
height: 90%;
border-radius: 50%;
content: '';
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
@-webkit-keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment