Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                input#playPause(type='checkbox', name='playPause')

- var orbs = 130
- var loops = 7
.scene
  .spiral
    - for (var i = 0; i < orbs*2; i++) {
    .pivot
      .orb
    - }
  label(for='playPause')
    .three
      div
      div
      div
    .two
      div
      div
    .one
        
              
            
!

CSS

              
                $orbs: 130;
$loops: 7;

body {
  margin: 0;
  background-color: #000;
  height: 100vh;
  font-size: .6vmin;
  overflow: hidden;
}

:where(body *),
body *::before {
  position: absolute;
  transform-style: preserve-3d;
}

body, .scene, .pivot {
  display: grid;
}

.scene {
  width: 100em;
  aspect-ratio: 1;
  place-self: center;
  perspective: 250em;
  animation: wobble 20s ease-in-out alternate infinite;
  animation-delay: -5s;
}

.spiral {
  inset: 0;
  --animDur: 6s;
  animation: spin var(--animDur) linear infinite;
}

.pivot {
  width: calc(50em - 50em*var(--step)/#{$orbs});
  height: 1px;
  right: 50em;
  top: calc(50em*((sin(var(--step)*90deg/#{$orbs}))*var(--dir) + 1));
  transform-origin: 100% 50%;
  rotate: y calc(360deg*#{$loops/$orbs}*var(--step)*var(--dir));
  --dir: 1;
  animation: pushX 18s ease-in-out alternate infinite; 
}

.pivot:nth-child(n+#{$orbs+1}) {
  --dir: -1;
}

.pivot:nth-child(n+#{$orbs+1}) .orb::before {
  background-color: #00f;
}

.orb {
  aspect-ratio: 1;
  animation: dmeter 18s ease-in-out alternate infinite;
}

.orb::before {
  content: '';
  inset: 0;
  border-radius: 50%;
  animation: counterSpin var(--animDur) linear infinite, shade calc(var(--animDur)) ease-in-out infinite;
  animation-delay: 0s, calc(var(--animDur)*(-1/#{$orbs/$loops}*(#{$orbs} + var(--step)*var(--dir)) + .25));
}

.orb::before,
:is(.three, .two) div,
.one {
  background-image: radial-gradient(at 30% 30%, #fff, hsl(calc(60deg*(var(--hue) - 1)) 100% 85%) 10%, hsl(calc(60deg*var(--hue)) 100% 25%) 50%, hsl(calc(60deg*(var(--hue) + .5)) 100% 10%) 66%, hsl(calc(60deg*(var(--hue) + .5)) 100% 5%) 75%);
  box-shadow: inset -1px -1px hsl(calc(60deg*(var(--hue) + 1)) 100% 50%);
}

/* PLAY/PAUSE TOGGLE */

input {
  display: none;
}

label {
  width: 20em;
  aspect-ratio: 1;
  align-self: center;
  animation: outtaWay 18s ease-in-out alternate infinite;
  position: relative;
}

label > div {
  display: flex;
  flex-direction: column;
  width: calc(100%/3);
}

label div {
  transition: .5s ease-in-out;
}

:is(.three,.two) div, .one {
  aspect-ratio: 1;
  background-color: #0f0;
  border-radius: 50%;
}

:is(.three,.two) div {
  position: relative;
}

.three {
  aspect-ratio: 1/3;
  --hue: 0;
}

.two {
  aspect-ratio: 1/2;
  left: calc(100%/3);
  top: calc(100%/6);
  --hue: 2;
}

.one {
  left: calc(200%/3);
  top: calc(100%/3);
  --hue: 4;  
}

#playPause:not(:checked) ~ .scene,
#playPause:not(:checked) ~ .scene *,
#playPause:not(:checked) ~ .scene *::before  {
  animation-play-state: paused;
}

#playPause:checked ~ .scene .one {
  top: calc(200%/3); 
}

#playPause:checked ~ .scene .two {
  left: calc(200%/3);
  top: 0;
  --hue: 4;
}

/* ANIMATION KEYFRAMES */

@keyframes wobble {
  0% {
    perspective-origin: 25% -50%;
  }
  100% {
    perspective-origin: 66% 150%;
  }
}


@keyframes spin {
  100% {
    rotate: y 360deg;
  }
}

@keyframes counterSpin {
  0% {
    rotate: y calc(-360deg*#{$loops/$orbs}*var(--step)*var(--dir));
  }
  100% {
    rotate: y calc(-360deg*(#{$loops/$orbs}*var(--step)*var(--dir) + 1));
  }
}

@keyframes pushX {
  0% {
    width: calc(50em*var(--step)/#{$orbs});
  }
  100% {
    width: calc(50em*(1 - var(--step)/#{$orbs}));  
  }
}

@keyframes dmeter {
  0% {
    width: calc(8em*var(--step)/#{$orbs});
  }
  100% {
    width: calc(8em*(1 - var(--step)/#{$orbs}));
  }
}

@keyframes shade {
  50% {
    filter: brightness(.25) saturate(2);
  }
}

@keyframes outtaWay {
  100% {
    translate: 0 -50em;
  }
}

/* LOOPS/ITERATIONS */

@for $i from 1 through $orbs {
  .pivot:nth-child(#{$i}),
  .pivot:nth-last-child(#{$i}) {
    --step: #{$i - 1};
  }
}

@for $i from 1 through 7 {
  .pivot:nth-child(7n+#{$i+1}) .orb
  {
    --hue: #{$i - 1};
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console