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. 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

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

              
                <header>
  <h1>CSS Transforms playground</h1>
  <div class='inputItem'> 
    <label>Perspective:</label>
    <input id="perspective" type="range" value='500' min="10" max="1000" step="10"/>
    <span>500px</span>
  </div>
</header>

<section>
  <div class='tWrap translateWrap'>
    <style contentEditable spellcheck=false> .translate{ transform: translate(20px, 50%) } </style>
    <p>▶</p>
    <div class='translate box'>translate</div>
  </div>
  
  <div class='tWrap scaleWrap'>
    <style contentEditable> .scale{ transform: scale(2, 0.5) } </style>
    <p>▶</p>
    <div class='scale box'>scale</div>
  </div>
  
  <div class='tWrap rotateWrap'>
    <style contentEditable spellcheck=false> .rotate{ transform: rotate(40deg) } </style>
    <p>▶</p>
    <div class='rotate box'>rotate</div>
  </div>
  
  <div class='tWrap rotatexWrap'>
    <style contentEditable> .rotateX{ transform: rotateX(40deg) } </style>
    <p>▶</p>
    <div class='rotateX box'>rotateX</div>
  </div>
  
  <div class='tWrap rotateyWrap'>
    <style contentEditable> .rotateY{ transform: rotateY(40deg) } </style>
    <p>▶</p>
    <div class='rotateY box'>rotateY</div>
  </div>
  
  <div class='tWrap rotatezWrap'>
    <style contentEditable spellcheck=false> .rotateZ{ transform: rotateZ(40deg) } </style>
    <p>▶</p>
    <div class='rotateZ box'>rotateZ</div>
  </div>
  
  <div class='tWrap skewWrap'>
    <style contentEditable spellcheck=false> .skew{ transform: skew(30deg, 20deg) } </style>
    <p>▶</p>
    <div class='skew box'>skew</div>
  </div>
  
  <div class='tWrap matrixWrap'>
    <style contentEditable spellcheck=false> .matrix{ transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) } </style>
    <p>▶</p>
    <div class='matrix box'>matrix</div>
  </div>
  
  <div class='tWrap matrix3dWrap'>
    <style contentEditable spellcheck=false> .matrix3d{ transform: matrix3d( 1.2, -0.08, 0, 0.004, -0.006, 1.6, 0, 0, 0, 0, 1, 0, 80, 50, 0, 1 ) } </style> 
    <p>▶</p>
    <div class='matrix3d box'>matrix3d</div>
  </div>
  
  <div class='tWrap translate3dWrap'>
    <style contentEditable spellcheck=false> .translate3d{ transform: translate3d(12px, 50%, 5em) } </style>
    <p>▶</p>
    <div class='translate3d box'>translate3d</div>
  </div>
  
  <div class='tWrap scale3dWrap'>
    <style contentEditable spellcheck=false> .scale3d{ transform: scale3d(2.5, 1.2, 0.3) } </style>
    <p>▶</p>
    <div class='scale3d box'>scale3d</div>
  </div>
  
  <div class='tWrap rotate3dWrap'>
    <style contentEditable spellcheck=false> .rotate3d{ transform: rotate3d(1, 2.0, 3.0, 10deg) } </style>
    <p>▶</p>
    <div class='rotate3d box'>rotate3d</div>
  </div>
</section>
              
            
!

CSS

              
                body{ font:14px Arial; padding-top:3em; }


@keyframes noTransformAnim{ 
    50%{ transform: none; } 
  }

header{
  position:fixed;
  top:0; left:0; right:0;
  z-index:10;
  background:#F1F1F1; 
  border-bottom:1px solid #DDD;
  box-shadow:0 0 10px rgba(black, .2);
  padding:10px;
  
  h1{ font-size:1.1em; display:inline-block; margin:0; padding:0; }
}

.inputItem{ 
  float:right;
  
  label{ vertical-align:middle; margin-right:1em; }
  input{ vertical-align:middle; width:350px; }
  span{ font-family:monospace; color:purple; }
}

section{
  $size: 300px;
  
  style{ 
    font:12px monospace; 
    white-space:nowrap; 
    position:absolute;
    display:block;
    top:0; 
    left:0;
    min-width:100%;
    background:#FFF; 
    color:#333; 
    padding:8px 10px; 
    margin-bottom:1em; 
    transition:.2s;
    outline:none;
  }
  
  .tWrap{ 
    perspective:500px; // default perspective
    position:relative;
    overflow:hidden; 
    padding-top:50px;
    margin:20px; 
    width:$size; 
    height:$size; 
    float:left;
    position:relative;
    border: 1px solid #EEE;
    transition:.2s .3s;
    transition-property:box-shadow, opacity;
    
    &:hover{ 
      overflow:visible; 
      z-index:5;
      box-shadow:0 0 0 9999px rgba(white, .5);
      transition-delay:0s;

      style{ z-index:1; background:lightyellow; }
    }
    
    > p{
      position:absolute;
      z-index:20;
      width:33px;
      height:33px;
      border-radius:40px 0 0 0;
      bottom:0;
      right:0;
      margin:0;
      font:20px/2 Arial;
      text-indent:15px;
      border-top:1px solid #DDD;
      border-left:1px solid #DDD;
      cursor:default;
      
      &:hover{
        background:#F1F1F1;
      }
    }

    > .box{
      position:absolute;
      top:0; right:0; bottom:0; left:0;
      width:$size/2; 
      height:$size/2; 
      margin:auto;
      background:linear-gradient(to bottom, #82BCF2 0%, transparent 300%);
      display:flex; 
      align-items:center; 
      justify-content: center;
      justify-items: center;
      color:#FFF; 
      font-weight:bold; 
      border-radius:3px;
    }
    
    > .lines{
      opacity: 0.5;
      position: absolute;
      width:100%;
      height:100%;
      top:0;
      left:0;
      
      .line{ 
        $color: #888;
        position: absolute; 

        &X{
          border-bottom: 1px dashed $color;
          height: 1px;
          left: 0;
          top: 50%;
          width: 100%;
        }

        &Y{
          border-left: 1px dashed $color;
          height: 100%;
          left: 50%;
          top: 0;
          width: 1px;
        }

        &Z{
          border-left: 2px dashed green;
          height: 100%;
          left: 50%;
          top: 0;
          transform: rotateX(90deg);
          width: 1px;
        }
      }
    }
    
    p:hover + .box{ animation:1s noTransformAnim infinite;  }
  
//     $transforms: scale, scale3d, translate, rotate, rotate3d, rotatex, rotatey, rotatez, skew, matrix, matrix3d, translate3d;  

//     @each $transform in $transforms {
//         &.#{$transform}Wrap{
//           p:hover + .box{ animation:1s #{$transform}Anim infinite; }
//         }
//     }
  }
  
}


$keyframes : (
    scale       : (2.2, 0.2),
    scale3d     : (3, 1, 0.6),
    translate   : (-20px, -50%) ,
    rotate      : (-20deg),
    rotate3d    : (5, 3.0, 5.0, 40deg),
    rotatex     : (-20deg),
    rotatey     : (-20deg),
    rotatez     : (-20deg),
    skew        : (-30deg, -20deg),
    matrix      : (0, 1.0, 3.2, 2.0, 5.0, 2.0),
    matrix3d    : ( 1.5, -0.03, 0, 0.002, -0.003, 1.2, 0, 0, 0, 0, 1, 0, 20, 50, 0, 1 ),
    translate3d : (22px, -50%, -5em)
);  
    
@each $key, $value in $keyframes {
  // @keyframes #{$key}Anim{ 
  //   50%{ transform: #{$key}unquote("(") $value unquote(")") } 
  // }
}
              
            
!

JS

              
                // by Yair Even-Or


var wrappers = $('.tWrap'),
    perspectiveInput = $('#perspective').on('input', onSetPerspective);

function onSetPerspective(e){
  perspectiveInput.next('span').text( this.value + 'px' );
  wrappers.css('perspective', this.value + 'px')
}
              
            
!
999px

Console