<div class="container">
  <div class="wrapper">
    <h2>CSS Transform Level 1: rotate3d(x, y, z, angle)</h2>
    
    <div class="camera"> 
      <div class="space"> 
        <div class="box old"></div> 
      </div> 
    </div>
  </div>

  <div class="wrapper">
    <h2>CSS Transform Level 2: rotate: x y z angle</h2>
    <div class="camera"> 
      <div class="space"> 
        <div class="box new"></div> 
      </div> 
    </div>
  </div>
  
  <aside>
  <div class="control">
    <label for="vectorX">X:</label>
    <input type="range" id="vectorX" step="0.1" value="0.5" min="0" max="1"/>
    <output id="outputX">0.5</output>
  </div>
  <div class="control">
    <label for="vectorY">Y:</label>
    <input type="range" id="vectorY" step="0.1"  value="0.3" min="0" max="1"/>
    <output id="outputY">0.3</output>
  </div>
  <div class="control">
    <label for="vectorZ">Z:</label>
    <input type="range" id="vectorZ" step="0.1"  value="0.2" min="0" max="1"/>
    <output id="outputZ">0.2</output>
  </div>
    
  <div class="control">
    <label for="angle">Angle:</label>
    <input type="range" id="angle" value="45" min="-360" max="360"/>
    <output id="outputAngle">45deg</output>
  </div>
</aside>
  
</div>


<footer>
  <p>请使用Firefox 72+浏览器查看Demo效果(^_^)!</p>
</footer>
@import url('https://fonts.googleapis.com/css?family=Gochi+Hand');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


body {
  margin: 0;
  padding: 0;
  background-color: #291642;
  font-family: 'Gochi Hand', sans-serif;
  color: #fff;
  font-size: 130%;
  letter-spacing: 0.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100vw;
  min-height: 100vh;
  
  .container {
    flex: 1;
    display: flex;
    width: 100vw;
    justify-content: center;
    align-items: center;
    padding-top: 20vh;
    padding-bottom: 40vh;
  }
  
  footer {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(#000, .75);
    width: 100vw;
    padding: 20px;
  }
}

.wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 4vh;
}

.camera {
  width: 40vh;
  height: 40vh;
  margin: 2vh 6vh;
  border: 1px dashed #f36;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective-origin:center center; 
  perspective:500px;
  padding: 2px;
}

.space{ 
  width:100%; height:100%; 
  border:1px dashed #fa90ef; 
  transform-style:3d; 
  
  display: flex;
  justify-content: center;
  align-items: center;
}


.box {
  width: 100%;
  height: 100%;
  transform-origin: center center;
  
  display: flex;
  justify-content: center;
  align-items: center;
  
  background: hsla(343,100%,58%,.3);
  
  &::after {
    content:'';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 100%;
  }
}

:root {
  --x: 0.5;
  --y: 0.3;
  --z: 0.2;
  --angle: 45deg;
}

.old {
  transform: rotate3d(var(--x), var(--y), var(--z), var(--angle));
}

.new {
  rotate: var(--x) var(--y) var(--z) var(--angle);
}

h2 {
  font-size: 1em;
}

aside {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 20vh;
  
  .item {
    margin: 2vh 0;
  }
}
View Compiled
const xVal = document.getElementById('vectorX')
const yVal = document.getElementById('vectorY')
const zVal = document.getElementById('vectorZ')
const angleVal = document.getElementById('angle')

const xOutputVal = document.getElementById('outputX')
const yOutputVal = document.getElementById('outputY')
const zOutputVal = document.getElementById('outputZ')
const angleOutputVal = document.getElementById('outputAngle')

const rootEle = document.documentElement

xVal.addEventListener('input', (e) => {
  console.log(e.currentTarget.value)
  rootEle.style.setProperty('--x', `${e.currentTarget.value}`);
  xOutputVal.textContent = `${e.currentTarget.value}`;
})

yVal.addEventListener('input', (e) => {
  console.log(e.currentTarget.value)
  rootEle.style.setProperty('--y', `${e.currentTarget.value}`);
  yOutputVal.textContent = `${e.currentTarget.value}`;
})

zVal.addEventListener('input', (e) => {
  console.log(e.currentTarget.value)
  rootEle.style.setProperty('--z', `${e.currentTarget.value}`);
  zOutputVal.textContent = `${e.currentTarget.value}`;
})

angleVal.addEventListener('input', (e) => {
  console.log(e.currentTarget.value)
  rootEle.style.setProperty('--angle', `${e.currentTarget.value}deg`);
  angleOutputVal.textContent = `${e.currentTarget.value}deg`;
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.