10
0

5_3D效果.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. perspective: 1000px;
  10. }
  11. .box{
  12. width: 200px;
  13. height: 200px;
  14. border:1px dashed black;
  15. margin: 100px auto;
  16. transform-style: preserve-3d;
  17. position: relative;
  18. }
  19. .div1,.div2{
  20. width: 200px;
  21. height: 200px;
  22. transition: all 1s linear;
  23. position: absolute;
  24. top:0;
  25. left: 0;
  26. }
  27. .box:hover .div1{
  28. transform:rotateY(180deg) translateZ(1px);
  29. }
  30. .div1{
  31. background-color: red;
  32. }
  33. .div2{
  34. background-color: blue;
  35. }
  36. .box:hover .div2{
  37. transform: rotateY(180deg) translateZ(2px);
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="box">
  43. <div class="div1"></div>
  44. <div class="div2"></div>
  45. </div>
  46. </body>
  47. </html>