opacity-preserve3d-4.html 791 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html><head>
  3. <style>
  4. .first {
  5. transform: translateZ(10px);
  6. background-color: blue;
  7. top: 0px;
  8. }
  9. .second {
  10. background-color: green;
  11. top: 40px;
  12. }
  13. .preserve {
  14. transform-style: preserve-3d;
  15. }
  16. .leaf {
  17. width: 100px;
  18. height: 100px;
  19. position:absolute;
  20. }
  21. </style>
  22. </head><body>
  23. <div class="preserve">
  24. <div class="preserve" style="opacity:0.5">
  25. <div class="leaf first"></div>
  26. <canvas class="leaf second" width="100px" height="100px" id="canvas"></canvas>
  27. </div>
  28. </div>
  29. <script>
  30. var canvas = document.getElementById("canvas");
  31. var ctx = canvas.getContext("2d");
  32. ctx.fillStyle = "red";
  33. ctx.fillRect(0, 0, 100, 100);
  34. </script>
  35. </body>
  36. </html>