<!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>旋转立方体</title>
</head>
<style>
body {
background-color: black;
}
* {
margin: 0;
padding: 0;
}
.wrap div {
width: 200px;
height: 200px;
position: absolute;
line-height: 200px;
font-size: 100px;
text-align: center;
left: 0px;
top: 0px;
transform-style: preserve-3d;
opacity: 0.5;
}
.wrap {
position: relative;
top: 200px;
left: 300px;
width: 200px;
height: 200px;
transform-style: preserve-3d;
transition: all 5s linear;
transform-origin: center;
}
.wrap div:nth-of-type(1) {
transform: rotateY(0deg) translateZ(100px);
background-color: yellow;
}
.wrap div:nth-of-type(2) {
transform: rotateY(180deg) translateZ(100px);
background-color: yellowgreen;
}
.wrap div:nth-of-type(3) {
transform: rotateX(90deg) translateZ(100px);
background-color: blueviolet;
}
.wrap div:nth-of-type(4) {
transform: rotateX(-90deg) translateZ(100px);
background-color: lightpink;
}
.wrap div:nth-of-type(5) {
transform: rotateY(90deg) translateZ(100px);
background-color: orchid;
}
.wrap div:nth-of-type(6) {
transform: rotateY(-90deg) translateZ(100px);
background-color: yellow;
}
.wrap:hover {
transform: rotateX(360deg) rotateY(360deg);
}
</style>
<body>
<div class="wrap">
<div>A</div>
<div>B</div>
<div>C</div>
<div>D</div>
<div>E</div>
<div>F</div>
</div>
</body>
</html>