<!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> html { perspective: 800px; } .cube { width: 200px; height: 200px; /* background-color: rgb(176, 170, 255); */ margin: 100px auto; transform-style: preserve-3d; animation: rotate 20s infinite linear; } /* 写不写都行,这里图片撑开了 */ .cube>div { width: 200px; height: 200px; /* 给整个元素设置半透明 */ opacity: 0.7; position: absolute; } .box1 { transform: rotateY(90deg) translateZ(100px); } .box2 { transform: rotateY(-90deg) translateZ(100px); } .box3 { transform: rotatex(90deg) translateZ(100px); } .box4 { transform: rotatex(-90deg) translateZ(100px); } .box5 { transform: translateZ(100px); } .box6 { transform: translateZ(-100px); } .box2>img { width: 200px; height: 200px; } .box3>img { width: 200px; height: 200px; } .box4>img { width: 200px; height: 200px; } .box5>img { width: 200px; height: 200px; } .box6>img { width: 200px; height: 200px; } @keyframes rotate { form { transform: rotateX(0) rotateZ(0) } to { transform: rotateX(1turn) rotateZ(1turn) rotateX(1turn) } } </style> </head> <body> <div class="cube"> <div class="box1"> <img src="./1.jpg" width="100%" height="100%"> </div> <div class="box2"> <img src="./2.jpg"> </div> <div class="box3"> <img src="./3.jpg"> </div> <div class="box4"> <img src="./4.jpg"> </div> <div class="box5"> <img src="./5.jpg"> </div> <div class="box6"> <img src="./6.jpg"> </div> </div> </body> </html>