JSFiddle - React, Tailwind, and code Playground

by wang lei

HTML

<div class="border">
<div id="box">
  <div>3</div>
</div>
<button id="btn">x轴旋转 上下翻转</button>
</div>
<div class="border">
<div id="box1">
  <div>3</div>
</div>
<button id="btn1">y轴旋转 左右</button>
</div>
<div class="border">
  <div id="box2">
  <div>3</div>
</div>
<button id="btn2">z轴旋转 绕圈</button>
</div>

CSS

#box, #box1,#box2 {
  width: 100px;
  height: 100px;
  background: rgba(0,0,255,0.75);
  position: relative;
}
#box div,#box1 div,#box2 div {
  text-align: center;
  line-height: 100px;
  font-size: 50px;
  color: #fff;
}
.border {
  border: 1px solid #000;
  width:120px;
  height: 120px;
  margin-top: 30px;
}

JavaScript

var box = document.getElementById("box");
var box1 = document.getElementById("box1");
var box2 = document.getElementById("box2");


  box.style.transform = "rotateX(-70deg)"

  box1.style.transform = "rotateY(70deg)"

  box2.style.transform = "rotateZ(30deg)"