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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="scene">
  <div class="paper-container" id="paper-container">
    <div class="paper paper-top">
      <div class="ladder-pattern ladder"></div>
      <div class="ladder-pattern shadow"></div>
    </div>
    <div class="paper paper-bottom">
      <div class="ladder-pattern ladder"></div>
      <div class="ladder-pattern shadow"></div>
    </div>
  </div>
</div>

<div class="interface">
  <p class="info">Click the paper to fold/unfold it</p>
  <label for="rotation-toggle" class="rotation-toggle">
    <input type="checkbox" id="rotation-toggle" />
    Rotation
  </label>
</div>
              
            
!

CSS

              
                :root {
  --scene-rotation-x: -45deg;
  --scene-rotation-y: 0deg;
  --fold-amount: 1;
  --fold-duration: 1s;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  perspective: 10000vmax;
  overflow: hidden;
  background: radial-gradient(#fff, oldlace 66%);
  color: #222;
}

body.is-rotating {
  --scene-rotation-x: calc(0deg - var(--cursor-y-1) * 90deg);
  --scene-rotation-y: calc(var(--cursor-x-1) * 90deg - 45deg);
}

body.is-unfolded {
  --fold-amount: 0;
}

.scene {
  transform:
    rotateX(var(--scene-rotation-x))
    rotateY(var(--scene-rotation-y));
  transform-style: preserve-3d;
}

.paper-container {
  transform: translateX(calc(-25% * var(--fold-amount)));
  transform-style: preserve-3d;
  transition: transform var(--fold-duration);
}

.paper {
  position: relative;
  width: 40vmin;
  height: 40vmin;
  background: #fff;
  cursor: pointer;
  transform-style: preserve-3d;
  transition:
    transform var(--fold-duration),
    background var(--fold-duration)
}

.paper-top {
  background: hsl(350, 83%, calc(88% + var(--fold-amount) * 2%));
  transform-origin: center bottom;
  transform:
    rotateY(45deg)
    rotateX(calc(90deg - 90deg * var(--fold-amount)))
    translateY(1px); /* to get rid of glitch at the fold */
}

.paper-bottom {
  background: hsl(350, 83%, 88%);
  transform-origin: center top;
  transform:
    rotateY(45deg)
    rotateX(90deg)
    translateY(-0.8px); /* to get rid of glitch at the fold */
}

.ladder-pattern {
  background: repeating-linear-gradient(
    transparent,
    transparent 9.9%,
    currentColor 10%,
    currentColor 12%
  );
  box-shadow:
    -1vmin 0 0 -.5vmin,
    1vmin 0 0 -.5vmin;
}

.shadow, .ladder {
  width: 10%;
  height: 70%;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.paper-top :where(.shadow, .ladder) {
  bottom: -.5vmin; /* to compensate for box-shadow gap */
}

.paper-bottom :where(.shadow, .ladder) {
  top: -.5vmin; /* to compensate for box-shadow gap */
}

.shadow {
  color: #0000001a;
}

.ladder {
  --skew: 22.5deg;
  color: #111;
}

.paper-top .ladder {
  transform-origin: center top;
  transform:
    translateX(-50%)
    skew(var(--skew));
}

.paper-bottom .ladder {
  transform-origin: center bottom;
  transform:
    translateX(-50%)
    skew(calc(var(--skew) * -1));
}

.interface {
  text-align: center;
}

.info {
  margin: .25em;
  font: italic bold clamp(18px, 28px, 5vmin)/1.5 "Times New Roman", georgia, serif;
}

.rotation-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .2em;
  font: normal 16px/1.5 helvetica, arial, sans-serif;
  cursor: pointer;
}
              
            
!

JS

              
                import { reportGlobals } from "https://enes.in/kicss/kicss.js"

// Creates custom CSS properties for cursor/touch position.
// Updated in real time.
reportGlobals({
  cursor: true
})

const query = document.querySelector.bind(document)

query('#paper-container').addEventListener('click', () => {
  document.body.classList.toggle('is-unfolded')
})

query('#rotation-toggle').addEventListener('click', () => {
  document.body.classList.toggle('is-rotating')
})
              
            
!
999px

Console