Created
October 19, 2016 12:17
-
-
Save icodesido/e9dfc123e455b34cf272253c9ad0ef6c to your computer and use it in GitHub Desktop.
Pure css loaders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$base-line-height: 24px; | |
$white: rgb(255,255,255); | |
$off-white: rgba($white, 0.2); | |
$spin-duration: 1s; | |
$pulse-duration: 750ms; | |
@keyframes spin { | |
0% { | |
transform: rotate(0deg); | |
} | |
100% { | |
transform: rotate(360deg); | |
} | |
} | |
@keyframes pulse { | |
50% { | |
background: $white; | |
} | |
} | |
html { | |
height: 100%; | |
} | |
body { | |
@extend html; | |
display: flex; | |
justify-content: space-around; | |
align-items: center; | |
background: #333333; | |
} | |
.loading { | |
border-radius: 50%; | |
width: $base-line-height; | |
height: $base-line-height; | |
border: .25rem solid $off-white; | |
border-top-color: $white; | |
animation: spin $spin-duration infinite linear; | |
&--double { | |
border-style: double; | |
border-width: .5rem; | |
} | |
} | |
.loading-pulse { | |
position: relative; | |
width: ($base-line-height / 4); | |
height: $base-line-height; | |
background: $off-white; | |
animation: pulse $pulse-duration infinite; | |
animation-delay: ($pulse-duration / 3); | |
&:before, &:after { | |
content: ''; | |
position: absolute; | |
display: block; | |
height: ($base-line-height / 1.5); | |
width: ($base-line-height / 4); | |
background: $off-white; | |
top: 50%; | |
transform: translateY(-50%); | |
animation: pulse $pulse-duration infinite; | |
} | |
&:before { | |
left: -($base-line-height / 2); | |
} | |
&:after { | |
left: ($base-line-height / 2); | |
animation-delay: ($pulse-duration / 1.5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment