实现步骤:
1 搭建HTML结构
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
<!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>Document</title>
<style>
.far {
perspective: 1000px;
}
section {
transform-style: preserve-3d;
position: relative;
width: 200px;
margin: 100px auto;
animation: move 6s linear infinite;
background: url(images/gwm.jpg) no-repeat;
}
section:hover {
animation-play-state: paused;
}
section div {
top: 0;
left: 0;
position: absolute;
}
section div:nth-child(1) {
transform: translateZ(300px);
}
section div:nth-child(2) {
/* 先旋转好了,再移动 */
transform: rotatey(60deg) translatez(300px);
}
section div:nth-child(3) {
transform: rotatey(120deg) translatez(300px);
}
section div:nth-child(4) {
transform: rotatey(180deg) translatez(300px);
}
section div:nth-child(5) {
transform: rotatey(240deg) translatez(300px);
}
section div:nth-child(6) {
transform: rotatey(300deg) translatez(300px);
}
img {
width: 200px;
}
@keyframes move {
0% {
transform: rotatey(0);
}
100% {
transform: rotatey(360deg);
}
}
</style>
</head>
<body>
<div class="far">
<section>
<div><img src="images/gwm.jpg" alt=""></div>
<div><img src="images/gwm.jpg" alt=""></div>
<div><img src="images/gwm.jpg" alt=""></div>
<div><img src="images/gwm.jpg" alt=""></div>
<div><img src="images/gwm.jpg" alt=""></div>
<div><img src="images/gwm.jpg" alt=""></div>
</section>
</div>
</body>
</html>