cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - 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.

            
              <ul class="card">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>
            
          
!
            
              .card {
  display: flex;
  --boards: 16; /* will be changed by JS, based on number of items */
  --dimension: calc(var(--boards) * 3px);
  --width: calc(var(--dimension) / var(--boards));
  transform-style: preserve-3d;
  transform: rotateY(var(--angle, -42deg)) rotateX(var(--angle-x));
  animation: flip 2500ms 0ms infinite alternate ease-in-out;
  --angle-x: .25deg;
  
  list-style: none;
}

li {
  height: var(--dimension);
  width: var(--width);
  position: relative;
  
  transform-style: preserve-3d;
}

li::before,
li::after {
  background-repeat: no-repeat;
  background-size: var(--dimension) calc(var(--dimension) * 9 / 16);
  background-position: calc(var(--offset-x, 0) * var(--dimension)) center;
  
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  
  transform:
    rotateY(calc(60deg * var(--direction, -1)));
  transform-origin: var(--origin-x, 100%) 50% 0px;
}

li::before { /* desert scene */
  background-image: url(https://images.unsplash.com/photo-1473580044384-7ba9967e16a0?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=53a6022c048f8595d90636e94b7fabf3);
}
li::after { /* Skyline and Homes */
  background-image: url(https://images.unsplash.com/photo-1522735555435-a8fe18da2089?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=d404d2ca601ddb2b3b33c4e3f41291b4);
  --direction: 1;
  --origin-x: 0%;
}

@keyframes flip {
  0%, 30% {
    transform: rotateY(-42deg) rotateX(var(--angle-x));
  }
  70%, 100% {
    transform: rotateY(42deg) rotateX(var(--angle-x));
  }
}






body {
  perspective: 1200px;
  
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(circle, hsl(199, 80%, 34%), hsl(199, 80%, 14%));
}
*, *::before, *::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

@media (max-width: 520px) {
  .card {
    --dimension: calc(var(--boards) * 2px);
  }
}
            
          
!
            
              let card = document.querySelector('.card');
let boards = Array.from(card.querySelectorAll('li'));

// Set CSS Variable to represent how many list items we have
card.style.setProperty('--boards', boards.length);

// Give each list item an offset for the background-position so the images appear complete across all the list items
boards.forEach((board, i) => {
  board.style.setProperty('--offset-x', -i / (boards.length));
});

// If browser supports Pointer Events, allow rotation about Y axis via pointer move, instead of using an infinite animation
const TOTAL_DEGREES = 84;
let clientWidth = window.innerWidth;
let step = TOTAL_DEGREES / clientWidth;
if ('PointerEvent' in window) {
  card.style.animationIterationCount = 2;
  document.body.addEventListener('pointermove', e => {
    card.style.setProperty('--angle', `${-42 + (e.clientX * step)}deg`)
  });
}

// Adjust Pointer Event ratios based on new screen width
window.addEventListener('resize', e => {
  clientWidth = window.innerWidth;
  step = TOTAL_DEGREES / clientWidth;
})





function orientIt(e) {
  var amount = (e.gamma / 12);
  card.style.setProperty('--angle', `${-e.gamma}deg`)
}

//Support for accelerometer around Y axis (e.g. in your hand facing you tilting it to the left and the right... best when orientationlocked). Disable when pointer events are happening.
if (window.DeviceOrientationEvent) {
  card.style.animationIterationCount = 2;
  if (window.PointerEvent) {
    document.body.addEventListener('pointermove', stopOrientation);
    document.body.addEventListener('pointercancel', startOrientation);
    document.body.addEventListener('pointerleave', startOrientation);
  }
  startOrientation();
}

function stopOrientation(e) {
  window.removeEventListener('deviceorientation', orientIt);
}
function startOrientation(e) {
  window.addEventListener('deviceorientation', orientIt);
}
            
          
!
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