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 type="checkbox" id="pcb">
<div class="pendulum">

  <div class="topbar">
    <div></div><div></div><div></div><div></div><div></div><div></div>
  </div>

  <div class="balls">
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
    <div class="ball">
      <div class="string"></div>
      <div class="string"></div>
      <div class="face"></div>
    </div>
  </div>

  <div class="floor">
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
    <div class="shadow"></div>
  </div>
</div>

<label for="pcb">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
    <path d="M 25 13 C 19.184825 13 13.344702 13.859292 8.8515625 15.605469 C 6.604993 16.478557 4.68813 17.572147 3.2851562 18.955078 C 1.8821826 20.338009 1 22.065021 1 24 C 1 25.765502 1.7336163 27.364275 2.9277344 28.673828 C 4.1218525 29.983381 5.7648812 31.042084 7.703125 31.912109 C 11.339472 33.544367 16.075891 34.455277 21 34.798828 L 21 41.044922 L 32.628906 32 L 21 22.955078 L 21 28.777344 C 16.699262 28.438697 13.10263 27.646111 10.683594 26.658203 C 9.3674634 26.12071 8.3719281 25.537579 7.7597656 25.021484 C 7.1476032 24.50539 7 24.096639 7 24 C 7 23.892861 7.1957082 23.405298 7.9492188 22.822266 C 8.7027293 22.239233 9.9098427 21.595327 11.490234 21.023438 C 14.651019 19.879656 19.303144 19 25 19 C 30.696856 19 35.348981 19.879656 38.509766 21.023438 C 40.090158 21.595327 41.297271 22.239233 42.050781 22.822266 C 42.804292 23.405298 43 23.892861 43 24 C 43 24.12216 42.684049 24.776886 41.615234 25.482422 C 40.546419 26.187958 38.876371 26.929655 36.728516 27.537109 L 36 27.744141 L 36 33.917969 L 37.240234 33.611328 C 40.490536 32.807479 43.346925 31.663594 45.466797 30.101562 C 47.586668 28.539531 49 26.457731 49 24 C 49 22.065021 48.117818 20.338009 46.714844 18.955078 C 45.31187 17.572147 43.395007 16.478557 41.148438 15.605469 C 36.655298 13.859292 30.815175 13 25 13 z M 25 15 C 30.614825 15 36.274467 15.85813 40.423828 17.470703 C 42.498509 18.27699 44.188911 19.273322 45.3125 20.380859 C 46.436089 21.488397 47 22.652479 47 24 C 47 25.711269 46.078379 27.166016 44.28125 28.490234 C 42.746774 29.620916 40.514291 30.536314 38 31.267578 L 38 29.154297 C 39.878459 28.560545 41.572518 27.905742 42.716797 27.150391 C 44.037732 26.278427 45 25.31184 45 24 C 45 22.884139 44.270238 22.011515 43.273438 21.240234 C 42.276636 20.468954 40.909311 19.764937 39.189453 19.142578 C 35.749737 17.89786 30.901144 17 25 17 C 19.098856 17 14.250263 17.89786 10.810547 19.142578 C 9.0906889 19.764937 7.7233644 20.468954 6.7265625 21.240234 C 5.7297606 22.011515 5 22.884139 5 24 C 5 25.016861 5.6222406 25.83547 6.4707031 26.550781 C 7.3191657 27.266093 8.4753645 27.916634 9.9277344 28.509766 C 12.832474 29.696029 16.925171 30.629986 21.945312 30.908203 L 23 30.966797 L 23 27.042969 L 29.373047 32 L 23 36.957031 L 23 32.970703 L 22.052734 32.919922 C 16.960744 32.651276 12.052997 31.673091 8.5214844 30.087891 C 6.7557282 29.295291 5.3421319 28.352525 4.40625 27.326172 C 3.4703681 26.299819 3 25.229498 3 24 C 3 22.652479 3.5639113 21.488397 4.6875 20.380859 C 5.8110887 19.273322 7.5014914 18.27699 9.5761719 17.470703 C 13.725533 15.85813 19.385175 15 25 15 z"/>
  </svg>
</label>
              
            
!

CSS

              
                * {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  background-color: #000;
  color: #fff;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-size: 40px;
  perspective: 50em;

  *:not(:empty) {
    transform-style: preserve-3d;
  }
}

input[type="checkbox"] {
  display: none;

  &:checked ~ .pendulum {
    --ry: 360deg;
  }
  &:checked ~ label {
    --ry: 180deg;
  }
}

label {
  position: fixed;
  top: calc(50% - 7em);
  cursor: pointer;
  transform: rotateY(var(--ry, 0));
  transition: transform 5s;

  &:hover > svg {
    opacity: 0.5;
  }

  svg {
    width: 3em; height: 2em;
    fill: #fff;
    opacity: 0.3;
  }
}

.pendulum {
  position: relative;
  transform: rotateY(var(--ry, 0deg));
  transition: transform 10s;
}

.topbar {
  position: absolute;
  top: -4em;

  & > div {
    position: absolute;
    width: 1em; height: var(--height, 1em);
    background-color: #420;
    transform: translate(-50%, -50%) var(--transform, );
    box-shadow: 0 0 1em #000 inset;
    opacity: 0.9;

    &:nth-child(1) { --transform: translateZ(8em);}
    &:nth-child(2) { --transform: rotateY(180deg) translateZ(8em);}

    @for $i from 0 to 4 {
      &:nth-child(#{$i + 3}) {
        --height: 16em;
        --transform: rotateZ(#{$i * 90deg}) rotateX(90deg) translateZ(0.5em);
      }
    }
  }
}

.balls {
  position: absolute;
  top: -3.5em;
}

.ball {
  position: absolute;
  animation: ballSwing var(--duration, 0s) calc(var(--duration, 0s) * -0.5) infinite ease-in-out alternate;

  @keyframes ballSwing {
    from { transform: translateZ(var(--tz, 0)) rotateZ(-45deg); }
    to { transform: translateZ(var(--tz, 0)) rotateZ(45deg); }
  }

  .string {
    position: absolute;
    left: -1px;;
    width: 2px; height: calc(var(--ty, 0) - 0.5em);
    background-color: hsla(var(--hue, 0), 75%, 75%, 0.1);
    transform: rotateX(var(--rx, -3deg));
    transform-origin: bottom;
    transform-style: preserve-3d;

    &:nth-child(2) { --rx: 3deg; }

    &::before, &::after {
      content: '';
      position: absolute;
      inset: 0;
      transform: rotateY(var(--ry, 120deg));
      background-color: inherit;
    }

    &::after { --ry: 240deg; }
  }

  & .face {
    position: absolute;
    animation: faceSwing var(--duration, 0s) calc(var(--duration, 0s) * -0.5) infinite ease-in-out alternate-reverse;
    transform-style: preserve-3d;

    @keyframes faceSwing {
      from { transform: translateY(var(--ty, 5em)) rotateZ(-45deg); }
      to { transform: translateY(var(--ty, 5em)) rotateZ(45deg); }
    }

    &::after {
      content: '';
      position: absolute;
      width: 1em; height: 1em;
      background-color: hsl(var(--hue, 0), 75%, 75%);
      background-image: radial-gradient(circle at top, #0000, #000);
      border-radius: 50%;
      box-shadow: 0 0 1em #000;
      transform: translate(-50%, -50%) rotateY(var(--ry, 720deg));
      transition: transform 10s;
    }
  }
}

.floor {
  position: absolute;
  top: 7em;
  width: 30em; height: 30em;
  background-color: #024;
  background-image: 
    radial-gradient(#0000, #000 15em),
    repeating-conic-gradient(from 20deg, #000 0 90deg, #0000 0 180deg);
  background-size: 100% 100%, 2em 2em;
  transform: translate(-50%, -50%) rotateX(90deg);
}

.shadow {
  position: absolute;
  left: 50%; top: calc(50% + var(--tz, 0em));
  width: calc(6em - var(--ty, 0) * 0.2); height: calc(8em - var(--ty, 0) * 0.2);
  border-radius: 50%;
  background-image: radial-gradient(#000, #0000 50%);
  animation: shadow var(--duration) calc(var(--duration, 0s) * -0.5) infinite ease-in-out alternate;
  transform: translate(-50%, -50%);

  @keyframes shadow {
    from { transform: translate(-50%, -50%) translateX(10em); }
    to { transform: translate(-50%, -50%) translateX(-10em); }

    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
  }
}

.ball, .shadow {
  @for $i from 0 to 15 {
    &:nth-child(#{$i + 1}) {
      --tz: #{$i - 7}em;
      --duration: #{30 / (30 - $i)}s; // #{math.div(36, 30 - $i)}s;
      --ty: #{6 + $i * 0.25}em;
      --hue: #{$i * 24};
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console