#box.box
  #box-inner.box-inner
    p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
dl.control
  dt rotateX
  dd
    input#rotateX(
      type='number'
      value = 45
    )
  dt rotateY
  dd
    input#rotateY(
      type = 'number'
      value = -45
    )
  dt rotateZ
  dd
    input#rotateZ(
      type = 'number'
      value = 0
    )
  dt perspective
  dd
    input#perspective(
      type = 'number'
      value = 400
      step = 10
      min = 0
    )
View Compiled
* {
  margin: 0;
}
body {
  font-size: 150%;
  font-family: source code pro;
}
.box {
  width: 240px;
  height: 320px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -160px;
}
.box-inner {
  width: 240px;
  height: 320px;
  position: relative;
  border-radius: 8px;
  background-color: #333;
  transform-style: preserve-3d;
  p {
    padding: 20px;
    color: #fff;
    font-size: 8px;
    text-align: justify;
    transform: translateZ(10px);
  }
}
.control {
  margin-top: 20px;
  margin-left: 20px;
  position: relative;
  dt {
    float: left;
    padding: 7px 0;
  }
  dd {
    margin-bottom: 10px;
    margin-left: 7em;
  }
}
input {
  font-size: 100%;
  &[type="number"] {
    width: 3em;
    padding: 5px;
    border: 2px solid #333;
    border-radius: 4px;
    text-align: right;
  }
}
var box = document.getElementById('box');
var box_in = document.getElementById('box-inner');
var input = {
  x: document.getElementById('rotateX'),
  y: document.getElementById('rotateY'),
  z: document.getElementById('rotateZ'),
  pers: document.getElementById('perspective')
};
var val = {
  x: input.x.value,
  y: input.y.value,
  z: input.z.value,
  pers: input.pers.value
};

var getInputVal = function() {
  val.x = input.x.value;
  val.y = input.y.value;
  val.z = input.z.value;
  val.pers = input.pers.value;
};

var render = function() {
  var box_style = '';
  box_style += 'rotateX(' + val.x + 'deg) ';
  box_style += 'rotateY(' + val.y + 'deg) ';
  box_style += 'rotateZ(' + val.z + 'deg) ';
  box_in.style.transform = box_style;
  box.style.perspective =  val.pers + 'px';
};

var renderloop = function() {
  getInputVal();
  render();
  requestAnimationFrame(renderloop);
};
renderloop();

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.