<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> @keyframes move{ from{transform:rotateX(0) rotateY(0);} to{transform:rotateX(360deg) rotateY(360deg);} } .wrap{ width: 200px; height: 200px; margin: 200px auto; position: relative; } .box{ width: 200px; height: 200px; transform-style:preserve-3d; animation:move 20s linear infinite; } .box div{ width: 200px; height: 200px; position: absolute; opacity: 0.9; transition:all 0.2s; } .box span{ display: block; width: 100px; height: 100px; position: absolute; top:50%; left: 50%; margin-top: -50px; margin-left: -50px; } .out_front{ transform:translateZ(100px); } .out_back{ transform:translateZ(-100px); } .out_left{ transform:rotateY(90deg) translateZ(-100px); } .out_right{ transform:rotateY(90deg) translateZ(100px); } .out_top{ transform:rotateX(90deg) translateZ(100px); } .out_bottom{ transform:rotateX(90deg) translateZ(-100px); } .box:hover .out_front{ transform:translateZ(200px); } .box:hover .out_back{ transform:translateZ(-200px); } .box:hover .out_left{ transform:rotateY(90deg) translateZ(-200px); } .box:hover .out_right{ transform:rotateY(90deg) translateZ(200px); } .box:hover .out_top{ transform:rotateX(90deg) translateZ(200px); } .box:hover .out_bottom{ transform:rotateX(90deg) translateZ(-200px); } .in_front{ transform:translateZ(50px); } .in_back{ transform:translateZ(-50px); } .in_left{ transform:rotateY(90deg) translateZ(-50px); } .in_right{ transform:rotateY(90deg) translateZ(50px); } .in_top{ transform:rotateX(90deg) translateZ(50px); } .in_bottom{ transform:rotateX(90deg) translateZ(-50px); } </style> </head> <body> <div class="wrap"> <div class="box"> <div class="out_front"> <img src="images/1.jpg"> </div> <div class="out_back"> <img src="images/2.jpg"> </div> <div class="out_left"> <img src="images/3.jpg"> </div> <div class="out_right"> <img src="images/4.jpg"> </div> <div class="out_top"> <img src="images/5.jpg"> </div> <div class="out_bottom"> <img src="images/6.jpg"> </div> <span class="in_front"><img src="images/01.jpg" ></span> <span class="in_back"><img src="images/02.jpg"></span> <span class="in_left"><img src="images/03.jpg" ></span> <span class="in_right"><img src="images/04.jpg" ></span> <span class="in_top"><img src="images/05.jpg" ></span> <span class="in_bottom"><img src="images/06.jpg" ></span> </div> </div> </body> </html>
第一次里边的小立方体总是在大立方体上边,设置z-index后总是在大立方体下边,hover放大后应该在大立方体中间,可是依然在大立方体后边,原来 原来 ....把in_..的类型给了img,应该在span上的。
时间: 2024-10-15 22:28:18