Skip to content

Instantly share code, notes, and snippets.

@Rplus
Created May 6, 2014 04:34
Show Gist options
  • Save Rplus/11553335 to your computer and use it in GitHub Desktop.
Save Rplus/11553335 to your computer and use it in GitHub Desktop.
A Pen by Rplus.
<h1>Pure CSS Loader</h1>
<div class="loader"></div>
@import "compass/css3";
html {
height: 100%;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
background: #222 -webkit-radial-gradient(50% 0, ellipse farthest-corner, #444 0%, #222 100%)
}
h1 {
margin-top: 60px;
color: #222;
font-weight: normal;
text-align: center;
text-shadow: 0 1px 1px rgba(255,255,255,0.1);
}
$dot-num: 8;
$dot-color: #fff;
$dot-size: 8px;
$dot-radius: 14px;
@function cycle-box-shadow ($n: $dot-num, $color: $dot-color) {
$deg: 360deg / $n;
$opacity-diff: 0.8 / $n;
$shadow: '';
@for $i from 1 through $n {
@if $i != 1 {
$shadow: $shadow + ',';
}
$shadow: '#{$shadow} ' + round($dot-radius * cos($deg * $i)) + ' ' + round($dot-radius * sin($deg * $i)) + ' ' + floor(0.5px * ($i - 1)) + ' ' + rgba($color, 1 - $i * $opacity-diff);
}
@return unquote($shadow);
}
.loader {
width: $dot-size;
height: $dot-size;
margin: 40px auto;
opacity: 0.5;
border-radius: 50%;
box-shadow: cycle-box-shadow();
transform-origin: 50%;
animation: load .9s steps($dot-num, end) infinite;
}
@keyframes load {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment