cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="display-case">
  <div class="pyramid">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div class="base"></div>
  </div>
  <div class="pyramid">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div class="base"></div>
  </div>
  <div class="pyramid">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div class="base"></div>
  </div>
</div>
            
          
!
            
              .pyramid {
  transform-style: preserve-3d;
  --unit: 1vmin;
  --side: calc(var(--unit) * 20);
  --rotateY: 0deg;
  --rotateX: 0deg;
  --fold: 0deg;
  position: relative;
  will-change: transform;
  transform: rotateX(var(--rotateX)) rotateY(var(--rotateY)) rotateZ(var(--rotateZ, 0deg)) translateZ(var(--z, 0));
  width: var(--side);
  height: var(--side);
  
  opacity: var(--opacity, 0);
  
  transition: transform 900ms ease-in-out;
}
.pyramid div {
  width: var(--side);
  height: var(--side);
  position: absolute;
  
  transition: transform 900ms ease-out, opacity var(--opacity-delay, 0ms) ease-in-out;
  transition-delay: 0ms, var(--opacity-delay, 0ms);
  opacity: var(--opacity, 0);
}
.pyramid .base {
  clip-path: none;
  background: hsla(338, 80%, 50%, 1);
}
.pyramid div:not(.base) {
  clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
  background: hsla(var(--hue, 183), 90%, 50%, .68);
  transform-origin: 0% 100%;
  transform: rotateZ(var(--rotateFaceZ, 0deg)) translate3d(var(--x, 0), var(--y, calc(var(--side) * -1)), 0) rotateX(var(--fold, 0deg));
}
.pyramid div:nth-child(2) {
  --hue: 188;
  --rotateFaceZ: 90deg;
  --x: calc(var(--side) * -1);
}
.pyramid div:nth-child(3) {
  --hue: 193;
  --rotateFaceZ: 180deg;
  --x: calc(var(--side) * -1);
  --y: 0;
}
.pyramid div:nth-child(4) {
  --hue: 198;
  --rotateFaceZ: 270deg;
  --x: 0;
  --y: 0;
}


/* stack the pyramids and fade them in */
.pyramid:nth-of-type(1) {
  --z: calc(var(--unit) * -2.67);
  --opacity: 1;
}
.pyramid:nth-of-type(2) {
  --rotateZ: 30deg;
  --opacity-delay: 900ms;
}
.pyramid:nth-of-type(3) {
  --rotateZ: 60deg;
  --z: calc(var(--unit) * 2.67);
  --opacity-delay: 1800ms;
}

/* rotate them as though they were in a ... display case */
.display-case {
  transform-style: preserve-3d;
  animation: model-it 2900ms 1600ms infinite linear;
}
@keyframes model-it {
  100% {
    transform: rotateY(360deg);
  }
}


body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  perspective: 800px;
  --inner: hsl(328, 70%, 40%);
  --middle: hsl(328, 70%, 45%);
  --outer: hsl(328, 70%, 50%);
  background: var(--outer);
  position: relative;
}
body::before, body::after {
  top: var(--offset);
  bottom: var(--offset);
  left: var(--offset);
  right: var(--offset);
  position: absolute;
  z-index: -1;
  content: '';
  transform: rotate(var(--body-rotate));
  clip-path: var(--path);
}
body::before {
  --offset: 15vmin;
  background: var(--middle);
  --body-rotate: 20deg;
  --path: polygon(0% 100%, 50% 0%, 100% 100%);
}
body::after {
  --offset: 20vmin;
  background: var(--inner);
  --body-rotate: 45deg;
  --path: polygon(0% 0%, 50% 100%, 100% 0%);
  animation-direction: reverse;
  animation-duration: 60000ms;
}
@keyframes rotate-background {
  100% {
    transform: rotate(calc(var(--body-rotate) + 360deg));
  }
}
*, *::before, *::after {
  box-sizing: border-box;
}
            
          
!
            
              var pyramids = Array.from(document.querySelectorAll('.pyramid'));


setTimeout(() => {
  pyramids.forEach(pyramid => {
    pyramid.style.setProperty('--fold', '-120deg');
    pyramid.style.setProperty('--rotateX', '90deg');
    pyramid.style.setProperty('--opacity', 1);
  });
  
}, 700);


/*
document.body.addEventListener('pointermove', e => {
    pyramids[0].style.setProperty('--rotateY', e.clientY + 'deg');
});
//*/
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console