css3 实现正方体3D旋转

亦凉 2022-06-04 00:06 457阅读 0赞

源代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .all{
  8. margin-left: 200px;
  9. width: 300px;
  10. height: 300px;
  11. perspective: 500px;
  12. border: 1px solid green;
  13. transform: rotate(30deg);
  14. transform-style: preserve-3d;
  15. transition: 6s;
  16. }
  17. .t1{
  18. width: 0px;
  19. height: 0px;
  20. margin-left: 100px;
  21. border: 50px solid red;
  22. transform: rotateX(90deg);
  23. transform-origin: bottom;
  24. }
  25. .t2{
  26. width: 0px;
  27. height: 0px;
  28. float: left;
  29. border:50px solid aquamarine;
  30. transform: rotateY(-90deg);
  31. transform-origin: right;
  32. }
  33. .t3{
  34. width: 0px;
  35. height: 0px;
  36. float: left;
  37. margin-left: 100px;
  38. border:50px solid blue ;
  39. transform: rotateY(90deg);
  40. transform-origin:left;
  41. }
  42. .t4{
  43. width: 0px;
  44. height: 0px;
  45. margin-left: 100px;
  46. margin-top: 100px;
  47. border: 50px solid orange;
  48. transform: rotateX(-90deg);
  49. transform-origin: top;
  50. }
  51. .t5{
  52. width: 0px;
  53. height: 0px;
  54. margin-left: 100px;
  55. margin-top: -200px;
  56. border: 50px solid pink;
  57. transform: rotateX(0deg);
  58. transform-origin: bottom;
  59. }
  60. .all:hover{
  61. transform: rotateX(360deg)rotateY(540deg)rotateZ(290deg)scale(1.2);
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div class="all">
  67. <div class="t1"></div>
  68. <div class="t2"></div>
  69. <div class="t3"></div>
  70. <div class="t4"></div>
  71. <div class="t5"></div>
  72. </div>
  73. </body>
  74. </html>

发表评论

表情:
评论列表 (有 0 条评论,457人围观)

还没有评论,来说两句吧...

相关阅读