opacity-preserve3d-3.html 868 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. .third {
  14. top: 80px;
  15. }
  16. .preserve {
  17. transform-style: preserve-3d;
  18. }
  19. .leaf {
  20. width: 100px;
  21. height: 100px;
  22. position:absolute;
  23. }
  24. </style>
  25. </head><body>
  26. <div class="preserve">
  27. <div class="preserve" style="opacity:0.5">
  28. <div class="leaf first"></div>
  29. <div class="leaf second"></div>
  30. <canvas class="leaf third" width="100px" height="100px" id="canvas"></canvas>
  31. </div>
  32. </div>
  33. <script>
  34. var canvas = document.getElementById("canvas");
  35. var ctx = canvas.getContext("2d");
  36. ctx.fillStyle = "red";
  37. ctx.fillRect(0, 0, 100, 100);
  38. </script>
  39. </body>
  40. </html>