cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-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.

            
              <div class="wrapper">
  
  <div class="square-wrap"><div class="square">CSS</div></div>
  
  <div class="inputs">
    <div class="input-wrap">
      <span class="result-X">Skew-X:</span>
      <input type="range" id="sliderX" min="-90" max="90" value="0" onchange="rangevalueX.value=value"/>
      <output id="rangevalueX">0deg</output>
   </div>
  
  <div class="input-wrap">
     <span class="result-Y">Skew-Y:</span>
     <input type="range" id="sliderY" min="-90" max="90" value="0" onchange="rangevalueY.value=value"/>
     <output id="rangevalueY">0deg</output>
  </div>
    
    
</div>

</div>
            
          
!
            
              body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.inputs {
  position:relative;
}
.input-wrap {
  padding-right:80px;
}
.wrapper {
  padding:20px 0;
  text-align:center;
}
.square-wrap {
  position:relative;
  width:200px;
  height:200px;
  overflow:visible;
  margin:0 auto;
  -webkit-perspective: 5000;
  -webkit-transform-style: preserve-3d;
  font-size:30px;
  color:#fff;
  line-height:100px;
}
.square {
  display:inline-block;
  position:absolute;
  width:100px;
  height:100px;
  background:#ee2a7b;
  overflow:hidden;
  margin-left:50px;
  margin-top:50px;
  left:0px;
  top:0px;
}
output {
  position:absolute;
}
span {
  margin:10px 10px 0 0;
}
            
          
!
            
              // Box
var box = document.querySelector('.square');

// Skew X Variables
var sliderx = document.getElementById("sliderX");
var rangevalueX = document.getElementById("rangevalueX");

// Skew Y Variables
var sliderY = document.getElementById("sliderY");
var rangevalueY = document.getElementById("rangevalueY");

// Property array
function getsupportedprop(proparray){
    var root=document.documentElement //reference root element of document
    for (var i=0; i<proparray.length; i++){ //loop through possible properties
        if (proparray[i] in root.style){ //if property exists on element (value will be string, empty string if not set)
            return proparray[i] //return that string
        }
    }
}
 
// Vendor Prefix Transform
var prefixtransform = getsupportedprop(["transform", "msTransform", "webkitTransform", "mozTransform", "oTransform"]);


// Slider X Function
sliderx.onchange = function(){
  
    if (rangevalueX <'50') {
    box.style[prefixtransform] = "skewX(-" + (sliderx.value) + 'deg)' + "skewY(-" + (sliderY.value) + 'deg)';
    rangevalueX.value = sliderx.value + "deg";
    }
    else if (rangevalueX >'50') {
    box.style[prefixtransform] = "skewX(" + sliderx.value + 'deg)' + "skewY(" + sliderY.value + 'deg)';
    rangevalueX.value = sliderx.value + "deg";
    }
    };

// Slider Y Function
sliderY.onchange = function(){
  
    if (rangevalueY <'50') {
    box.style[prefixtransform] = "skewX(-" + (sliderx.value) + 'deg)' + "skewY(-" + (sliderY.value) + 'deg)';
    rangevalueY.value = sliderY.value + "deg";
    }
    else if (rangevalueY >'50') {
    box.style[prefixtransform] = "skewX(" + sliderx.value + 'deg)' + "skewY(" + sliderY.value + 'deg)';
    rangevalueY.value = sliderY.value + "deg";
    }
    };

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console