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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

              <h2>Animation with CSS Variables</h2>
    <div class="controls">
      <input type="range" id="x" min="0" max="360" value="10">
      <input type="range" id="y" min="0" max="360" value="10">
      <input type="range" id="z" min="0" max="360" value="10">


    <div class="display">
      <img class="photo" src="http://unsplash.it/800/500?image=1011">

    <p class="love">Made by <a href="http://twitter.com/wesbos">@wesbos</a> 🔥</p>

    <p class="love">Chrome 49+, Firefox 31+</p>
                 :root {
     --x: 10deg;
     --y: 10deg;
     --z: 10deg;
     --base: #1497AD;
   .photo {
     transform: rotateX(var(--x)) rotateY(var(--y)) rotateZ(var(--z));
     transition: all 0.5s;
     border: 20px solid white;
     box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        misc styles, nothing to do with CSS variables
   body {
     text-align: center;
     background: #ffc600;
     color: white;
     font-family: 'helvetica neue', sans-serif;
     font-weight: 100;
     font-size: 50px;
   .display {
     perspective: 800px;
   .controls {
     margin-bottom: 50px;
     position: relative;
     z-index: 2;
   a {
     color: var(--base);
     text-decoration: none;
                    // get the inputs
      const inputs = [].slice.call(document.querySelectorAll('.controls input'));

      // listen for changes
      inputs.forEach(input => input.addEventListener('change', handleUpdate));
      inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));

      function handleUpdate(e) {
        // append 'px' to the end of spacing and blur variables
        const suffix = (this.id === 'base' ? '' : 'px');
        var property = `--${this.id}`;
        // remove the last one so we don't pollute the element with inline styles
        // update the element. Note: We are doing this on <html>, but varaibles can be scoped to ANY element
        document.documentElement.style.setProperty(property, this.value + 'deg');
Loading ..................