练习题3_旋转立方体.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. body{
  9. margin: 0;
  10. height: 100vh;
  11. background-color: cornflowerblue;
  12. /* overflow: hidden; */
  13. perspective: 1000px;
  14. }
  15. .box{
  16. width: 200px;
  17. height: 200px;
  18. border:1px dashed black;
  19. position: fixed;
  20. top: 50%;
  21. left: 50%;
  22. margin-top: -100px;
  23. margin-left: -100px;
  24. transform-style: preserve-3d;
  25. /* transform: rotateY(30deg); */
  26. animation-name: foo;
  27. animation-duration: 2s;
  28. animation-iteration-count: infinite;
  29. animation-timing-function:linear;
  30. }
  31. @keyframes foo {
  32. 0%{
  33. transform: rotateY(0deg);
  34. }
  35. 100%{
  36. transform: rotateY(360deg);
  37. }
  38. }
  39. .box div{
  40. width: 200px;
  41. height: 200px;
  42. position: absolute;
  43. top:0;
  44. left: 0;
  45. background-size: 100% 100%;
  46. opacity: 0.5;
  47. border-radius: 15px;
  48. }
  49. .box .one{
  50. background-image: url("./img/a.jpg");
  51. transform: translateZ(100px);
  52. }
  53. .box .two{
  54. background-image: url("./img/b.jpg");
  55. transform: translateZ(-100px);
  56. }
  57. .box .three{
  58. background-image: url("./img/c.jpg");
  59. transform: rotateY(90deg) translateZ(100px);
  60. }
  61. .box .four{
  62. background-image: url("./img/d.jpg");
  63. transform: rotateY(90deg) translateZ(-100px);
  64. }
  65. .box .five{
  66. background-image: url("./img/e.jpg");
  67. transform: rotateX(90deg) translateZ(100px);
  68. }
  69. .box .six{
  70. background-image: url("./img/f.jpg");
  71. transform: rotateX(90deg) translateZ(-100px);
  72. }
  73. </style>
  74. </head>
  75. <body>
  76. <div class="box">
  77. <div class="one"></div>
  78. <div class="two"></div>
  79. <div class="three"></div>
  80. <div class="four"></div>
  81. <div class="five"></div>
  82. <div class="six"></div>
  83. </div>
  84. </body>
  85. </html>