画布重叠 两个canvas怎么重叠在一起

来源:8-6 总结:Canvas高级内容

慕斯3556369

2017-12-09 10:50

两个canvas怎么重叠在一起

写回答 关注

3回答

  • Riddle2000
    2020-02-13 08:58:34

    赞!好用

  • Tom_Kwok
    2017-12-22 02:05:37
      <!-- 上面的HTML结构有误 -->
      <div class="canvas-wrapper">
          <canvas id="canvas-1" class="canvas"></canvas>
          <canvas id="canvas-2" class="canvas"></canvas>
      </div>


  • Tom_Kwok
    2017-12-22 02:03:27
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>canvas重叠</title>
        <style>
          .canvas-wrapper {
            position: relative;
            width: 600px;
            height: 600px;
            border: 1px solid black;
          }
          .canvas {
            width: 400px;
            height: 400px;
          }
          #canvas-1 {
            background-color: #058;
            top: 0;
            left: 0;
          }
          #canvas-2 {
            background-color: red;
            top: 200px;
            left: 200px;
          }
          .canvas {
            position: absolute;
          }
        </style>
      </head>
      <body>
        <div>
          <canvas id="canvas-1"></canvas>
          <canvas id="canvas-2"></canvas>
        </div>
      </body>
    </html>


Canvas绘图详解

Canvas系列教程第二课,详解Canvas各接口,让同学彻底掌握Canvas绘图

72881 学习 · 422 问题

查看课程

相似问题