0%
前言
正方体旋转案例
源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> * { margin: 0px; padding: 0px; }
.outer { width: 200px; height: 200px; margin: 100px auto; perspective: 3000px; }
ul { position: relative; width: 200px; height: 200px; list-style: none; transform-style: preserve-3d; animation: donghua 2s linear 0s infinite; }
li { position: absolute; width: 200px; height: 200px; }
li:nth-child(1) { background: red; transform: translateZ(100px); }
li:nth-child(2) { background: orange; transform: translateZ(-100px); }
li:nth-child(3) { background: yellow; transform: rotateX(90deg) translateZ(100px); }
li:nth-child(4) { background: green; transform: rotateX(90deg) translateZ(-100px); }
li:nth-child(5) { background: cyan; transform: rotateY(90deg) translateZ(100px); }
li:nth-child(6) { background: purple; transform: rotateY(90deg) translateZ(-100px); }
@-webkit-keyframes donghua { form{ transform: rotateX(0deg) rotateY(0deg); } to{ transform: rotateX(360deg) rotateY(360deg); } }
</style> </head> <body>
<div class="outer"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div>
</body> </html>
|
完成
参考文献
哔哩哔哩——web前端小清风