20.旋转立方体.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. }
  12. body {
  13. perspective: 1000px;
  14. }
  15. #container {
  16. width: 200px;
  17. height: 200px;
  18. margin: 100px auto;
  19. border: 1px solid #000;
  20. position: relative;
  21. transform-style: preserve-3d;
  22. animation: run 4s linear infinite;
  23. }
  24. #container div {
  25. width: 200px;
  26. height: 200px;
  27. border: 1px solid #000;
  28. position: absolute;
  29. opacity: .5;
  30. }
  31. #box1 {
  32. background: url('./images/a.jpg');
  33. transform: translateZ(100px);
  34. }
  35. #box2 {
  36. background: url('./images/b.jpg');
  37. transform:rotateY(180deg) translateZ(100px);
  38. }
  39. #box3 {
  40. background: url('./images/c.jpg');
  41. transform:rotateY(90deg) translateZ(100px);
  42. }
  43. #box4 {
  44. background: url('./images/d.jpg');
  45. transform:rotateY(-90deg) translateZ(100px);
  46. }
  47. #box5 {
  48. background: url('./images/e.jpg');
  49. transform:rotateX(90deg) translateZ(100px);
  50. }
  51. #box6 {
  52. background: url('./images/f.jpg');
  53. transform:rotateX(-90deg) translateZ(100px);
  54. }
  55. @keyframes run {
  56. 100% {
  57. transform: rotateY(360deg);
  58. }
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div id="container">
  64. <div id="box1"></div>
  65. <div id="box2"></div>
  66. <div id="box3"></div>
  67. <div id="box4"></div>
  68. <div id="box5"></div>
  69. <div id="box6"></div>
  70. </div>
  71. </body>
  72. </html>