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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <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>
<footer>Things get a little more involved if <code>CSS.registerProperty()</code> is supported (like Chrome with Experimental Web Platform features flag enabled)</footer>
            
          
!
            
              :root {
  --size: 6vmax;
}
li {
  background: hsl(
    var(--hue, 343), 
    calc(var(--saturation, 1) * 100%),
    calc(var(--lightness, 1) * 100%));
  -webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%); /* oh Safari 11 */
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  
  animation: basic-dance 3000ms infinite alternate cubic-bezier(.57,-0.1,.53,1);
}

@keyframes basic-dance {
  0% {
    transform: scale(.96);
  }
  20%, 40% {
    transform: scale(.8);
  }
  100% {
    transform: scale(0);
  }
}

/* Get fancy if possible */
.css-vars-in-keyframes-supported li {
  animation-name: fancy-dance;
  animation-timing-function: ease-in-out;
  animation-duration: 28000ms;
  transform: 
    scale(var(--s1))
    rotateX(var(--rx3))
    rotateY(var(--ry3))
    translateX(var(--tx1))
    translateY(var(--ty1))
    rotateZ(var(--rz1))
    rotateX(var(--rx1))
    rotateY(var(--ry1))
    translateX(var(--tx2))
    rotateX(var(--rx2))
    rotateY(var(--ry2))
    translateY(var(--ty2))
    rotateZ(var(--rz2));
  
  transition: 
    --rx3 450ms ease-out,
    --ry3 450ms ease-out;
}

@keyframes fancy-dance {
  9%, 100% {
    --s1: .8;
    --ty1: 0vmax;
  }
  24%, 98% {
    --tx1: 0vmax;
    --tx2: 0vmax;
  }
  30%, 81% {
    --tx1: -2vmax;
    --tx2: 2vmax;
  }
  25.5% {
    --ty1: 3.5vmax;
    --ty2: -3.5vmax;
  }
  28%% {
    --rz1: 0deg;
    --rz2: 0deg;
  }
  100% {
    --rz1: -360deg;
    --rz2: 360deg;
  }
  40%, 91% {
    --rz1: -310deg;
    --rz2: 310deg;
  }
  18% {
    --rx1: 0deg;
    --ry2: 0deg;
  }
  60%, 91%, 100% {
    --rx1: 1800deg;
    --ry2: -720deg;
  }
  10%, 58% {
    --rx2: 0deg;
    --ry1: 0deg;
  }
  98%, 100% {
    --rx2: 720deg;
    --ry1: 1800deg;
  }
  28% {
    --rx2: -180deg;
  }
}


/* Tiling for Grid */

ul {
  display: grid;
  grid-template-columns: repeat(20, var(--size));
  grid-template-rows: repeat(24, calc(var(--size) * .75));
  height: 100vh;
  width: 100%;
  transform: translate(calc(var(--size) * -1), calc(var(--size) * -1));
  perspective: 100vmax;
}
li {
  grid-column-end: span 2;
  grid-row-end: span 2;
  height: calc(var(--size) * 2);
  
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 4vmax;
}
li:first-of-type,
li:nth-of-type(20),
li:nth-of-type(39),
li:nth-of-type(58),
li:nth-of-type(77),
li:nth-of-type(96),
li:nth-of-type(115),
li:nth-of-type(134) {
  grid-column-start: 2;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(circle, hsl(183, 10%, 12%), hsl(183, 10%, 8%));
  font-family: system-ui, 'Segoe UI', sans-serif;
}
*, *::before, *::after {
  box-sizing: border-box;
}

/* for the dancing of comedy/tragedy (see JS) */
li {
  color: hsl(
    var(--hue, 343), 
    calc(var(--saturation, 1) * 100%),
    calc(var(--lightness, 1) * 100%));
}


footer {
  color: white;
  background: rgba(0,0,0,0.6);
  padding: .7rem;
  text-align: center;
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  line-height: 1.5;
  font-size: 14px;
}
code {
  font-family: monospace;
}
.css-vars-in-keyframes-supported footer {
  display: none;
}
            
          
!
            
              if (window.CSS && CSS.registerProperty) {
  document.documentElement.classList.add('css-vars-in-keyframes-supported');
  
  ['x1','x2','x3','y1','y2','y3','z1','z2']
    .forEach(prop => {
      CSS.registerProperty({
        name: `--t${prop}`,
        syntax: '<length>',
        inherits: false,
        initialValue: '0px'
      });
      CSS.registerProperty({
        name: `--r${prop}`,
        syntax: '<angle>',
        inherits: true,
        initialValue: '0deg'
      });
    });
  
  CSS.registerProperty({
    name: `--s1`,
    syntax: '<number>',
    inherits: false,
    initialValue: 1.01
  });
}


//A little variation on hsl values and delay
let tiles = Array.from(document.querySelectorAll('li'));
let hue = 343;
tiles.forEach((tile, i) => {
  tile.style.setProperty('--hue', hue);
  tile.style.setProperty('--saturation', 1 - (i % 11 * .01));
  tile.style.setProperty('--lightness', .5 - (i % 6 * .03));
  tile.style.animationDelay = `${Math.random() * 260}ms`;
  
  //Uncomment if you want a dance of the comedy and tragedy
  // tile.style.background = 'transparent';
  // tile.textContent = ': ) :'
});


//And with a mouse or pointer events (sorry, iOS), add an extra X/Y rotation (only for the fancy "We're just animating the custom properties thanks to Houdini" dance)
let tileGroup = document.querySelector('ul');
let lastTimeout = 0;
const deg = 125;
const move = throttle(e => {
  tileGroup.style.setProperty('--rx3', `${(e.clientY * 2) / window.innerHeight * deg - deg}deg`)
  tileGroup.style.setProperty('--ry3', `${e.clientX * 2 / window.innerWidth * deg - deg}deg`)
}, 100);
const leave = (e => {
  clearTimeout(lastTimeout);
  tileGroup.style.setProperty('--rx3', `0deg`)
  tileGroup.style.setProperty('--ry3', `0deg`)
});
if (window.PointerEvent) { //Since as of 2/2018 this is only in Chrome Canary, this will always be true
  document.addEventListener('pointermove', move)
  document.addEventListener('pointerleave', leave)
  document.addEventListener('pointercancel', leave)
} else {
  document.addEventListener('mousemove', move)
  document.addEventListener('mouseout', leave)
}

function throttle(fn, threshhold, scope) {
  threshhold || (threshhold = 250);
  var last;
  return function () {
    var context = scope || this;

    var now = +new Date,
        args = arguments;
    if (last && now < last + threshhold) {
      // hold on to it
      clearTimeout(lastTimeout);
      lastTimeout = setTimeout(function () {
        last = now;
        fn.apply(context, args);
      }, threshhold);
    } else {
      last = now;
      fn.apply(context, args);
    }
  };
}


            
          
!
999px
Loading ..................

Console