HTML Implementation Layer Overlay

Source: Internet
Author: User

<div id= "Canvasesdiv" style= "position:relative; width:400px; height:300px "><canvas id=" Layer1 "style=" z-index:1; Position:absolute; left:0px; top:0px; "height=" 300px "width=" >this text is displayed if your browser does no support HTML5 CANVAS.</CANVAS&G T;<canvas id= "Layer2" style= "Z-INDEX:2; Position:absolute; left:20px; top:10px; "height=" 300px "width=" >this text is displayed if your browser does no support HTML5 canvas.</canvas& gt;</div><script>  layer1 = document.getElementById ("Layer2"). GetContext ("2d"); Layer2 = document.getElementById ("Layer2"). GetContext ("2d"); Layer1.moveto (0);  Layer1.lineto (0, 50); Layer1.lineto (50, 100); Layer1.lineto (100, 50); Layer1.lineto (50, 0); Layer1.stroke (); Layer2.moveto (  ); Layer2.lineto (50, 52); Layer2.moveto (a);  Layer2.lineto (60, 52); Layer2.moveto (a);  Layer2.lineto (70, 52); Layer2.stroke ();</script>
<canvas id= "MYCANVAS1" width= "500px" height= "400px" ></canvas>   <canvas id= "MyCanvas2" width= " 500px "height=" 400px "style=" Z-index:2 "></canvas>    <script>      var context1 = document.getElementById ("MYCANVAS1"). GetContext ("2d");      var context2 = document.getElementById ("MyCanvas2"). GetContext ("2d");        Context1.fillstyle = "Red";      Context1.fillrect (50,50,100,100);      Context1.fillstyle = "Rgba (0,0,255,0.4)";      Context1.fillrect (80,80,100,100);      Context1.fill ();      Context2.fill ();  </script>  

  

HTML Implementation Layer Overlay

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.