<!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> *{ margin: 0; padding: 0; } .wrap{ position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; height: 300px; width: 300px; border: 1px solid; /* 会作用给后代元素 */ perspective: 200px; /* 只会作用给子元素 */ transform-style: preserve-3d; } .liBox{ position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; height: 100px; width: 100px; transform-style: preserve-3d; transform-origin: center center -50px; transition: 1s linear; } .liBox > div{ position: absolute; height: 100px; width: 100px; background-color: pink; font: bold 20px/100px "微软雅黑"; text-align: center; } .liBox > div:nth-child(3){ left: -100px; transform-origin: right; transform: rotateY(-90deg); } .liBox > div:nth-child(4){ right: -100px; transform-origin: left; transform: rotateY(90deg); } .liBox > div:nth-child(5){ top: -100px; transform-origin: bottom; transform: rotateX(90deg); } .liBox > div:nth-child(6){ bottom: -100px; transform-origin: top; transform: rotateX(-90deg); } .liBox > div:nth-child(2){ transform: translateZ(-100px) rotateX(180deg); } .liBox > div:nth-child(1){ z-index: 1; } .wrap:hover .liBox{ transform: rotateX(360deg); } </style> </head> <body> <div class="wrap"> <div class="liBox"> <div>前</div> <div>后</div> <div>左</div> <div>右</div> <div>上</div> <div>下</div> </div> </div> </body> </html>
效果:

浙公网安备 33010602011771号