<!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;
transform-style: preserve-3d;
}
.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; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap div:nth-of-type(2) {
transform: rotateY(180deg) translateZ(100px);
/* background-color: yellowgreen; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap div:nth-of-type(3) {
transform: rotateX(90deg) translateZ(100px);
/* background-color: blueviolet; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap div:nth-of-type(4) {
transform: rotateX(-90deg) translateZ(100px);
/* background-color: lightpink; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap div:nth-of-type(5) {
transform: rotateY(90deg) translateZ(100px);
/* background-color: orchid; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap div:nth-of-type(6) {
transform: rotateY(-90deg) translateZ(100px);
/* background-color: yellow; */
background-image: url(./卡通图片.JPG);
background-size: contain;
}
.wrap:hover {
transform: rotateX(360deg) rotateY(360deg);
}
</style>
<body>
<div class="wrap">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>