两个canvas怎么重叠在一起
赞!好用
<!-- 上面的HTML结构有误 --> <div class="canvas-wrapper"> <canvas id="canvas-1" class="canvas"></canvas> <canvas id="canvas-2" class="canvas"></canvas> </div>
<!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>