当前位置:   article > 正文

Web前端---旋转立方体

Web前端---旋转立方体

1.实现代码:

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. body{
  10. perspective: 3000px;
  11. }
  12. @keyframes myAnimation {
  13. from{
  14. transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  15. }
  16. to{
  17. transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
  18. }
  19. }
  20. .container{
  21. margin:200px;
  22. position: relative;
  23. transform-style: preserve-3d;
  24. animation-name: myAnimation;
  25. animation-duration: 8s;
  26. animation-timing-function: linear;
  27. animation-delay: 0s;
  28. animation-iteration-count: infinite;
  29. }
  30. .container:hover>img:first-child{
  31. left: -300px;
  32. }
  33. .container:hover>img:nth-child(2){
  34. top: -300px;
  35. }
  36. .container:hover>img:nth-child(3){
  37. left: 300px;
  38. }
  39. .container:hover>img:nth-child(4){
  40. top: 300px;
  41. }
  42. .container:hover>img:nth-child(6){
  43. transform: translateZ(300px);
  44. }
  45. .container:hover>img:nth-child(5){
  46. transform: translateZ(-100px);
  47. }
  48. .container>img{
  49. width: 200px;
  50. height: 200px;
  51. position: absolute;
  52. border: 1px solid red;
  53. transition: 3s
  54. }
  55. .container>img:first-child{
  56. left: -200px;
  57. transform-origin: right;
  58. transform: rotateY(90deg);
  59. }
  60. .container>img:nth-child(2){
  61. top:-200px;
  62. transform-origin: bottom;
  63. transform:rotateX(-90deg);
  64. }
  65. .container>img:nth-child(3){
  66. left: 200px;
  67. transform-origin: left;
  68. transform:rotateY(-90deg)
  69. }
  70. .container>img:nth-child(4){
  71. top: 200px;
  72. transform-origin: top;
  73. transform: rotateX(90deg);
  74. }
  75. .container>img:nth-child(6){
  76. transform: translateZ(200px);
  77. }
  78. </style>
  79. </head>
  80. <body>
  81. <div class="container">
  82. <img src="https://img1.baidu.com/it/u=1512380121,3450729774&fm=253&fmt=auto&app=138&f=JPEG?w=174&h=164" alt="">
  83. <img src="https://p1.hoopchina.com.cn/personPic/6de79b9b-ed1f-4141-85bb-838e7cd9a48e.jpg?x-oss-process=image/resize,w_800/format,jpg" alt="">
  84. <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F7fcf99e0-3485-4d80-bf92-f66f4572c5d2%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1705924570&t=a2eae4d55f7c75ebbb3baec353d92066" alt="">
  85. <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F0231c359-3671-4cc4-b162-dbab09b5b0f9%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1705924570&t=84ae2e05d00fc492e6297b839fdea8d6" alt="">
  86. <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F1f2afeb2-253a-4be1-87dd-6d266517f4f7%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1705924570&t=fe1bd16abbdeba072c1baff5a4683a5d" alt="">
  87. <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F91baae03-e1f4-4662-b16a-270ff58c5d60%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1705924570&t=ece1717322c1ec6c6922c80794318218" alt="">
  88. </div>
  89. </body>
  90. </html>

旋转立方体

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/96836
推荐阅读
相关标签
  

闽ICP备14008679号