旋转木马案例
请寻找同样像素的图片
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
perspective: 1200px;
}
.box {
position: relative;
width: 300px;
height: 200px;
margin: 200px auto;
/* background-color: #ccc; */
animation: rotate 10s linear infinite;
transform-style: preserve-3d;
}
.box div {
position: absolute;
left: 0;
top: 0;
width: 300px;
height: 200px;
background-size: contain;
}
.box div:nth-child(1) {
background-image: url(./images/1.jpg);
transform: rotateY(0) translateZ(300px);
z-index: 6;
}
.box div:nth-child(2) {
background-image: url(./images/2.jpg);
z-index: 5;
transform: rotateY(60deg) translateZ(300px);
}
.box div:nth-child(3) {
background-image: url(./images/3.jpg);
z-index: 4;
transform: rotateY(120deg) translateZ(300px);
}
.box div:nth-child(4) {
background-image: url(./images/4.jpg);
z-index: 3;
transform: rotateY(180deg) translateZ(300px);
}
.box div:nth-child(5) {
background-image: url(./images/5.jpg);
z-index: 2;
transform: rotateY(240deg) translateZ(300px);
}
.box div:nth-child(6) {
background-image: url(./images/6.jpg);
z-index: 1;
transform: rotateY(300deg) translateZ(300px);
}
@keyframes rotate {
0% {
transform: rotateY(0);
}
100% {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div class="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>