octocatstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <div class="loader">
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
  <span class="loader-block"></span>
</div>
            
          
!

CSS

            
              @import "compass/css3";


$blockSize: 2em;
//$blockSize: 6vmin; // Try this in Firefox! Viewport based size, which doesn't work in Canary at the moment

// Play with these to see what you get
$delay: .065s;
$duration: .88s;
$startingColor: #fdfdfd;
$endingColor: #dadada;

// Calculate some values
$blockMargin: $blockSize / 3;
$loaderSize: $blockSize * 3 + $blockMargin * 2;

@mixin animation-delay( $delay ) {
  -webkit-animation-delay: $delay;
  animation-delay: $delay;
}

// Official syntax supported by IE10, FF16, Opera 12.1,
// so we're only going to add the webkit prefix
@mixin animation( $ani1:null, $ani2:null ) {
  @if ($ani2 != null) {
    -webkit-animation: $ani1, $ani2;
    animation: $ani1, $ani2;
  }
  
  @else if ($ani1 != null) {
    -webkit-animation: $ani1;
    animation: $ani1;
  }
}

body {
  text-align: center;
}

.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: $loaderSize;
  height: $loaderSize;
  margin-left: -$loaderSize/2;
  margin-top: -$loaderSize/2;
}

.loader-block {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  opacity: 0;
  width: $blockSize;
  height: $blockSize;
  background: $startingColor;
  @include animation(show $duration step-end infinite alternate,
    pulse $duration linear infinite alternate);
}



// Second
.loader-block:nth-child(1) {
  @include translate(0, 0);
  @include animation-delay(1 * $delay);
}

// Ninth
.loader-block:nth-child(2) {
  @include translate($blockSize + $blockMargin, 0);
  @include animation-delay(2 * $delay);
}

// Fourth
.loader-block:nth-child(3) {
  @include translate(($blockSize * 2) + ($blockMargin * 2), 0);
  @include animation-delay(3 * $delay);
}

// Sixth
.loader-block:nth-child(4) {
  @include translate(0, $blockSize + $blockMargin);
  @include animation-delay(5 * $delay);
}

// Third
.loader-block:nth-child(5) {
  @include translate($blockSize + $blockMargin, $blockSize + $blockMargin);
  @include animation-delay(2 * $delay);
}

// Eighth
.loader-block:nth-child(6) {
  @include translate(($blockSize * 2) + ($blockMargin * 2), $blockSize + $blockMargin);
  @include animation-delay(7 * $delay);
}

// Seventh
.loader-block:nth-child(7) {
  @include translate(0, ($blockSize * 2) + ($blockMargin * 2));
  @include animation-delay(6 * $delay);
}

// Fifth
.loader-block:nth-child(8) {
  @include translate($blockSize + $blockMargin, ($blockSize * 2) + ($blockMargin * 2));
  @include animation-delay(4 * $delay);
}

// First
.loader-block:nth-child(9) {
  @include translate(($blockSize * 2) + ($blockMargin * 2), ($blockSize * 2) + ($blockMargin * 2));
}


@-webkit-keyframes pulse {
  from,
  40% { 
    background: $startingColor;
  }
  to {
    background: $endingColor;
  }
}

@-webkit-keyframes show {
  from, 40% { opacity: 0; }
  41%, to { opacity: 1; }
}

@keyframes pulse {
  from,
  40% { 
    background: $startingColor;
  }
  to {
    background: $endingColor;
  }
}

@keyframes show {
  from, 40% { opacity: 0; }
  41%, to { opacity: 1; }
}


/* Body styling */
html,
body {
  height: 100%;
}

body {
  @include background(#999 radial-gradient(circle farthest-side, #333, #111));
}
            
          
!

JS

            
              // A CSS Loader based on gif (http://imgur.com/iWGr9AP)

// A pen by @Vestride
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console