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

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.

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

              
                <div class="shredder">
  <div class="shredder__side shredder__top">
    <div class="shredder__paper shredder__paper--input">
      <div class="shredder__paper-inner">
        <p class="shredder__text" contenteditable>Type your text here then press the green button to shred</p>
      </div>
    </div>
    <div class="shredder__paper shredder__paper--output">
      <div class="shredder__paper-inner"></div>
    </div>
  </div>
  <div class="shredder__side shredder__front">
    <button class="shredder__btn" aria-label="activate shredder"></button>
  </div>
</div>
              
            
!

CSS

              
                :root {
  font-size: 72vmin;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  perspective: 1em;
  overflow: hidden;
  background-image: radial-gradient(
    circle farthest-corner at 10% 20%,
    #61baff 0%,
    #a6effd 90%
  );
}

.shredder {
  transform-style: preserve-3d;
  transform: rotateX(-40deg) rotateY(0deg);

  &__side {
    position: absolute;
    width: 1em;
    height: 0.2em;
    border: 0.003em solid rgba(0, 0, 0, 0.01);
    transform-style: preserve-3d;
  }

  &__top {
    transform-origin: 50% 100%;
    transform: translate(-50%, -0.2em) rotateX(90deg);
    background-image: linear-gradient(#999, #bbb);

    &::before {
      content: "";
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0.8em;
      height: 0.03em;
      background-image: linear-gradient(#555, #333);
      border: 0.002em solid rgba(0, 0, 0, 0.01);
      transform: translate(-50%, -50%);
    }
  }

  &__front {
    transform: translateX(-50%);
    background-image: linear-gradient(#bbb, #999);
  }

  &__btn {
    appearance: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.12rem;
    height: 0.12rem;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.75);
    text-transform: uppercase;
    background-color: #298a29;
    border-radius: 20%;
    border: none;
    border-top: 0.005rem solid rgba(0, 0, 0, 0.15);
    transform: translate(-50%, -50%);
    transition: box-shadow 200ms, border-width 150ms linear;
    cursor: pointer;

    &::before {
      content: "";
      position: absolute;
      left: 50%;
      width: 0.075rem;
      height: 0.075rem;
      border-radius: 50%;
      border: 0.01rem solid rgba(0, 0, 0, 0.5);
      border-top-color: transparent;
      transform: translate(-50%, -50%);
    }

    &::after {
      content: "";
      position: absolute;
      top: 0.02rem;
      left: 50%;
      width: 0.01rem;
      height: 0.04rem;
      background-color: rgba(0, 0, 0, 0.5);
      transform: translateX(-50%);
    }

    .shred:not(.complete) & {
      border-width: 0.001em;
      box-shadow: 0 0 0.02em #19db19;
      background-image: radial-gradient(#19db19, #298a29);
    }
  }

  &__paper {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    left: 50%;
    height: 0.5em;
    width: 0.75em;
    overflow: hidden;
    transform-style: preserve-3d;

    p {
      font-family: Arial, sans-serif;
      font-size: 0.05em;
      font-weight: 900;
      line-height: 1.3;
      text-align: center;
      text-transform: uppercase;
      color: #111;
      overflow-wrap: anywhere;
    }

    &--input {
      top: -0.4em;
      transform-origin: 0 100%;
      transform: rotateX(-90deg) translateX(-50%);

      .shredder__paper-inner {
        background-color: #fafafa;
        border-top: 0.001em solid #eee;
        transition-timing-function: ease-in;

        .shred & {
          transform: translateY(100%);
        }
      }
    }

    &--output {
      top: 50%;
      transform-origin: 0 0;
      transform: rotateX(-90deg) translate(-50%, 0.3em);

      p {
        width: 100%;
        background: repeating-linear-gradient(
          90deg,
          #111,
          #111 3%,
          transparent 3%,
          transparent 4%
        );
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
      }

      .shredder__paper-inner {
        transform: translateY(-100%);
        transition-delay: 2s;
        transition-timing-function: ease-out;
        background-image: repeating-linear-gradient(
          90deg,
          #fafafa,
          #fafafa 3%,
          transparent 3%,
          transparent 4%
        );

        .shred & {
          transform: translateY(0);
        }
      }
    }

    &-inner {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      transform-style: preserve-3d;
      transition: transform 3s linear;
      overflow: hidden;
    }
  }
}

              
            
!

JS

              
                const shredder = document.querySelector(".shredder");
const shredderBtn = document.querySelector(".shredder__btn");
const shredderText = document.querySelector(".shredder__text");
const shredderPaperOutput = document.querySelector(
  ".shredder__paper--output .shredder__paper-inner"
);
const shredDuration = 5100;

shredderBtn.addEventListener("click", () => {
  if (!shredder.classList.contains("shred")) {
    // Copy text from input paper to output paper
    const outputText = document.createElement("p");

    shredderText.removeAttribute("contenteditable");

    outputText.textContent = shredderText.textContent;

    shredderPaperOutput.appendChild(outputText);

    // Add class for shred transition
    shredder.classList.add("shred");

    // Add class to reset shredder button style
    setTimeout(() => shredder.classList.add("complete"), shredDuration);
  }
});

              
            
!
999px

Console