console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D正方体</title>
</head>
<body>
<div class="box">
<div class="stage">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
}
.box {
width: 200px;
height: 200px;
margin: 30px auto;
}
.stage {
position: relative;
width: 200px;
height: 200px;
perspective: 10000px;
transition: all 5s ease;
transform-style: preserve-3d;
}
.stage:hover {
transform: rotateX(360deg) rotateY(360deg);
}
.stage div {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
font: bold 80px/200px "arial";
text-align: center;
}
.stage div:nth-child(1) {
background-color: rgba(255, 0, 0, 0.5);
transform: translateZ(100px);
}
.stage div:nth-child(2) {
background-color: rgba(0, 255, 0, 0.5);
transform: rotateX(90deg) translateZ(100px);
}
.stage div:nth-child(3) {
background-color: rgba(0, 0, 255, 0.5);
transform: rotateY(-90deg) translateZ(100px);
}
.stage div:nth-child(4) {
background-color: rgba(255, 255, 0, 0.5);
transform: rotateY(90deg) translateZ(100px);
}
.stage div:nth-child(5) {
background-color: rgba(255, 0, 255, 0.5);
transform: rotateX(270deg) translateZ(100px);
}
.stage div:nth-child(6) {
background-color: rgba(0, 255, 255, 0.5);
transform: rotateX(180deg) translateZ(100px);
}