Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="container left">
  <main class="scene left">
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
  </main>
</div>
<div class="container right">
  <aside class="scene right">
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
    <div class="spiral-follower"></div>
  </aside>
</div>

<form>
  <div>
    <label for="mode">3D Mode</label>
    <select id="mode">
      <option value="0">None</option>
      <option value="1">Google Cardboard</option>
      <option value="2" selected>3D Glasses</option>
    </select>
  </div>
  <div>
    <label for="animate">Animation</label>
    <select id="animate">
      <option value="paused">Paused</option>
      <option value="running" selected>Running</option>
    </select>
  </div>
</form>
            
          
!

CSS

            
              body {
  --base-size: 30vmin;
  --size: var(--base-size);
  --duration: 238640ms;
  --enable-3d: 2;
  --animate: paused;
  --perspective: 30vmin;
}

@media screen and (prefers-reduced-motion: reduced) {
  body {
    --enable-3d: 0;
    --animate: paused;
    --perspective: 80vmin;
  }
}
.container {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  width: calc(0% + calc(var(--enable-3d) * 50%));
  min-width: 50%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.container.right {
  opacity: var(--enable-3d);
  left: calc(100% - var(--enable-3d) * 50%);
}
.scene {
  width: var(--size);
  height: var(--size);
  position: absolute;
  margin-bottom:-5rem;
  
  perspective: var(--perspective);
  transform-style: preserve-3d;
  perspective-origin: var(--o-x) 50%;
  --diff: 6px;
  --o-x: calc(50% - var(--diff));
  mix-blend-mode: multiply;
}
.scene.right {
  --o-x: calc(50% + var(--diff));
}

.spiral-follower {
  transform-style: preserve-3d;
  border: 1.5vmin solid currentColor;
  border-radius: 50%;
  width: var(--size);
  height: var(--size);
  position: absolute;
  top: 50%;
  left: 50%;
  will-change: transform;
  
  animation: spiral var(--duration) infinite alternate ease-in-out;
  animation-play-state: var(--animate, paused);
  
  color: hsl(var(--hue, 0), 100%, calc(-50% + var(--enable-3d) * 50%));
}
.scene.left .spiral-follower {
  --hue: 180;
}
@keyframes spiral {
  0%, 1% {
    transform: translate3d(-50%,-50%,calc(var(--base-size) * -.25)) rotateZ(0deg) rotateY(0deg) rotateX(0deg);
  }
  100% {
    transform: translate3d(-50%,-50%,calc(var(--base-size) * -.25)) rotateZ(2970deg) rotateY(8080deg) rotateX(12160deg);
  }
}
@keyframes fade {
  30%, 96% {
    opacity: 1
  }
  0%, 100% {
    opacity: 0;
  }
}









body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: hsl(223, 50%, 104%);
/*   background-image: 
    radial-gradient(circle, hsla(180,100%,50%,.25) .3vmin, transparent .3vmin),
    radial-gradient(circle, hsla(180,100%,50%,.25) .5vmin, transparent .5vmin),
    radial-gradient(circle, hsla(0,100%,50%,.25) .3vmin, transparent .3vmin),
    radial-gradient(circle, hsla(0,100%,50%,.25) .5vmin, transparent .5vmin);
  background-size: 10.667vmin 10.667vmin;
  background-position: 3vmin 0vmin, 8.333vmin 5.333vmin, 0vmin 0vmin, 6.333vmin 5.333vmin; */
}
*, *::before, *::after {
  box-sizing: border-box;
}
form {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  font-family: system-ui, sans-serif;
  font-size: 14px;
}
form div {
  display: flex;
  flex-direction: column;
  margin: 0 1rem;
}
form select {
  font-size: 16px;
}
            
          
!

JS

            
              const mode = document.getElementById('mode');
mode.addEventListener('change', e => {
  document.body.style.setProperty('--enable-3d', e.currentTarget.value);
});

const playState = document.getElementById('animate');
playState.value = getComputedStyle(document.body).getPropertyValue('--animate').trim();
playState.addEventListener('change', e => {
  document.body.style.setProperty('--animate', e.currentTarget.value);
});


//This JS is only here because I wanted to make it so you can add as many circles as you want and didn't want to use Sass for offsetting the animation delays.
var followers = document.querySelectorAll('.left .spiral-follower');
var followersRight = document.querySelectorAll('.right .spiral-follower');
var duration = parseFloat(getComputedStyle(document.body).getPropertyValue('--duration'));

for (var i = 0, l = followers.length; i < l; ++i) {
  var follower = followers[i];
  var follower2 = followersRight[i];
  var delay = -(i * duration / l+ 8800) + 'ms';
  follower.style.setProperty('animation-delay', delay);
  follower2.style.setProperty('animation-delay', delay);
  follower.style.setProperty('--size', `${10 + 50 * i / followers.length}vmin`);
  follower2.style.setProperty('--size', `${10 + 50 * i / followers.length}vmin`);
}
            
          
!
999px

Console