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

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

Code Indentation


Save Automatically?

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

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              @import "nib"

If you change the $ballCount count, don't forget to increase the createBalls in the styles as well.
$radius = 500px
$ballSize = 60px
$ballCount = 8
$duration = 1s
$spokeColor = rgba(255,255,255,0.0)

$delayAmt = ($duration/$ballCount)
$pathAngle = 180/$ballCount

@keyframes ballMove 
  0% { transform: translate(0,0) } 
  100% { transform: translate($radius - $ballSize,0) }

  background : #333
  text-align : center

  background : transparent
  width : $radius 
  height : $radius 
  border-radius : 50%
  position : relative
  margin : 0 auto
  for i in 0..$ballCount
      transform : rotate((i*$pathAngle)deg)
      width : 100%
      height : 1px
      position : absolute
      top : 50%
      left : 0%
      background-color: $spokeColor
      display : block
      position : absolute
      top : -($ballSize/2)px
      width : $ballSize
      height : @width
      box-shadow : 0 0 10px rgba(0,0,0,0.75)
      border : 1px solid rgba(0,0,0,0.5)
      border-radius : 50%
      animation-name : ballMove
      animation-duration : $duration
      animation-timing-function : ease-in-out
      animation-iteration-count : infinite
      animation-direction : alternate      
      animation-delay : (i*$delayAmt)
      background-color : hsla((360/$ballCount)*i, 100%, 50%, 1)

createSpinner('#spinner', 8);

// Create a Shadow DOM element
function createSpinner (id, dotCount) {
  var host = document.querySelector(id);
  var shadow = host.createShadowRoot();
  shadow.innerHTML = createDots(dotCount);

// Generate the Template
function createDots(num) {
  var result = '';
  for (i=1; i<num+1; i++) { 
    result += '<div class="path p'+i+'" pseudo="x-spinner-path'+i+'"><div pseudo="x-spinner-ball'+i+'"></div></div>'; 
  return result;

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.


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