<!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>
<style>
@keyframes roll {
from {
transform: rotateX(0) rotateY(0) rotateZ(0);
}
to {
transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
}
}
* {
margin: 0;
padding: 0;
}
div {
width: 200px;
height: 200px;
background-color: skyblue;
line-height: 200px;
text-align: center;
color: white;
font-size: 100px;
position: absolute;
}
.wrap {
padding: 100px;
background-color: transparent;
transform-style: preserve-3d;
animation: roll 8s linear infinite;
}
.wrap div:nth-of-type(1) {
transform: rotateY(-90deg) translateZ(100px);
}
.wrap div:nth-of-type(2) {
transform: rotateY(90deg) translateZ(100px);
background-color: tomato;
}
.wrap div:nth-of-type(3) {
transform: rotateX(90deg) translateZ(100px);
background-color: plum;
}
.wrap div:nth-of-type(4) {
transform: rotateX(-90deg) translateZ(100px);
background-color: greenyellow;
}
.wrap div:nth-of-type(5) {
transform: translateZ(100px);
background-color: gold;
}
.wrap div:nth-of-type(6) {
transform: rotateX(180deg) translateZ(100px);
background-color: hotpink;
}
</style>
</head>
<body>
<div class="wrap">
<div><img src="img/1.jpg" width="200px" height="200px"></div>
<div><img src="img/2.jpg" width="200px" height="200px"></div>
<div><img src="img/3.jpg" width="200px" height="200px"></div>
<div><img src="img/4.jpg" width="200px" height="200px"></div>
<div><img src="img/5.jpg" width="200px" height="200px"></div>
<div><img src="img/6.jpg" width="200px" height="200px"></div>
</div>
</body>
</html>