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

              
                <main>
  <section>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <span></span>
  </section>
  <section class="spinning">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <span></span>
  </section>
</main>

<form>
  <p>
    <label for="rate">Playback Rate</label>
    <input type="range" id="rate" min="-1" max="1" step=".05" value="1" />
    <output id="rate-output" for="rate">Current: 1x</output>
  </p>
  <p>
    <label for="opacity">Half Circle Opacity</label>
    <input type="range" id="opacity" min="0" max="1" step=".025" value="1" />
    <output id="opacity-output" for="opacity">Current: 1</output>
  </p>
</form>
              
            
!

CSS

              
                section {
  --dim: 45vmin;
  margin: 2.5vmin;
  --num: 20;
  width: var(--dim);
  height: var(--dim);
  position: relative;
}
.no-waapi .spinning {
  animation: spin 9700ms infinite linear;
  animation-duration: calc(16.66666666667 * 6ms);
}
div {
  position: absolute;
  width: var(--diameter, var(--dim));
  height: var(--diameter, var(--dim));
  background: hsl(0, 100%, 98%);
  border-radius: 50%;
  color: hsl(220, 100%, 43%);
  color: black;
  border: calc(var(--dim) / 75) solid currentColor;
  left: 50%;
  top: 50%;
  transform:
    translate(-50%, -50%)
    rotate(var(--rotate, 0deg));
}
div:nth-of-type(1) {
  border:none;
}
div:nth-of-type(n+2) {
  //clip-path: polygon(0% 50%, 0% 21%, 50% 50%);
  clip-path: polygon(0% 50%, 0% 0%, 21% 0%, 50% 50%);
}
div:nth-of-type(2) {
  --diameter: calc(var(--dim) * 19 / var(--num));
}
div:nth-of-type(3) {
  --diameter: calc(var(--dim) * 18 / var(--num));
}
div:nth-of-type(4) {
  --diameter: calc(var(--dim) * 17 / var(--num));
}
div:nth-of-type(5) {
  --diameter: calc(var(--dim) * 16 / var(--num));
}
div:nth-of-type(6) {
  --diameter: calc(var(--dim) * 15 / var(--num));
}
div:nth-of-type(7) {
  --diameter: calc(var(--dim) * 14 / var(--num));
}
div:nth-of-type(8) {
  --diameter: calc(var(--dim) * 13 / var(--num));
}
div:nth-of-type(9) {
  --diameter: calc(var(--dim) * 12 / var(--num));
}
div:nth-of-type(10) {
  --diameter: calc(var(--dim) * 11 / var(--num));
}
div:nth-of-type(11) {
  --diameter: calc(var(--dim) * 10 / var(--num));
}
div:nth-of-type(12) {
  --diameter: calc(var(--dim) * 9 / var(--num));
}
div:nth-of-type(13) {
  --diameter: calc(var(--dim) * 8 / var(--num));
}
div:nth-of-type(14) {
  --diameter: calc(var(--dim) * 7 / var(--num));
}
div:nth-of-type(15) {
  --diameter: calc(var(--dim) * 6 / var(--num));
}
div:nth-of-type(16) {
  --diameter: calc(var(--dim) * 5 / var(--num));
}
div:nth-of-type(17) {
  --diameter: calc(var(--dim) * 4 / var(--num));
}
div:nth-of-type(18) {
  --diameter: calc(var(--dim) * 3 / var(--num));
}
div:nth-of-type(19) {
  --diameter: calc(var(--dim) * 2 / var(--num));
}

/* Different effects when bars are in different locations
/* */
div:nth-of-type(n+5) {
  --base-deg: 60deg;
  --rotate: calc(var(--base-deg) * .4);
}
div:nth-of-type(n+8) {
  --rotate: calc(var(--base-deg) * .8);
}
div:nth-of-type(n+11) {
  --rotate: calc(var(--base-deg) * 1.2);
}
div:nth-of-type(n+14) {
  --rotate: calc(var(--base-deg) * 1.6);
}
div:nth-of-type(n+17) {
  --rotate: calc(var(--base-deg) * 2);
}
/**/


div:nth-of-type(20) {
  //display:none;
  --rotate: 0deg;
  border: none;
  background: currentColor;
  //background: hsl(340,80%,98%);
  opacity: var(--half-opacity, 1);
  clip-path: polygon(0% 50%, 100% 50%, 100% 100%, 0% 100%);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

span {
  display: block;
  position:absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: hsl(223, 84%, 13%);
  width: calc(var(--dim) / 24);
  height: calc(var(--dim) / 24);
  border-radius: 50%;
}

main {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

body {
  background: hsl(223, 84%, 13%);
  height: 100vh;
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  align-items: stretch;
  overflow: hidden;
}
*, *::before, *::after {
  box-sizing: border-box;
}


form {
  padding: 1rem;
  color: #fdfeff;
  font-family: system-ui, 'Segoe UI', -apple-system, sans-serif;
  background: hsla(0, 0%, 0%, .2);
  display: flex;
  justify-content: space-between;
}
form p {
  display: flex;
  flex-direction: column;
}
input[type=range] {
  max-width: 15rem;
}
.no-waapi form {
  display: none;
}

              
            
!

JS

              
                const spinningTop = document.querySelector('.spinning');

//If Web Animations API is supported, allow playback control
if (spinningTop.animate) {
  //Soon CSS Animations will be exposed to WAAPI controls, but no stable browser supports it yet, so will just recreate CSS animation in WAAPI for better support now.
  
  let animation = spinningTop.animate({
    transform: ['rotate(0deg)', 'rotate(360deg)']
  }, {
    duration: 100,
    iterations: Infinity
  });
  
  let output = document.getElementById('rate-output');
  let outputOpacity = document.getElementById('opacity-output');
  
  document.getElementById('rate').addEventListener('input', function(e) {
    var value = parseFloat(e.currentTarget.value);
    if (animation.updatePlaybackRate) {
      animation.updatePlaybackRate(value);
    } else {
      animation.playbackRate = value;
    }
    output.value = `Current: ${value}x`;
  });
  
  document.getElementById('opacity').addEventListener('input', function(e) {
    let value = e.currentTarget.value;
    document.documentElement.style.setProperty('--half-opacity', value);
    outputOpacity.value = `Current: ${value}`;
  });
} else {
  document.documentElement.classList.add('no-waapi');
}
              
            
!
999px

Console