在 HTML 中单击 canvas 下的按钮

Click button under canvas in HTML

我在 html 中有一个按钮。

按钮部分被 canvas 覆盖(透明背景),我无法在 canvas 覆盖的区域点击它。

图形丰富的表格非常复杂,移动这些东西需要大量工作。

是否可以为鼠标点击制作 canvas "invisible"?

您可以在 css 中使用 z-index 来应用 z-order。 z-index

也许用 z-index 试试?

按钮: z-index: 1;

Canvas: z-index: 0;

只需制作按钮position:relative。它将允许您单击按钮。

button {
    position: relative;
}

canvas {
    background-color: black;
    margin-left: -30px;
}
<button>click</button>
<canvas width="100" height="100" />

在按钮上尝试 z-index 和 canvas。

button, canvas {
    position: relative;
}

button {
    z-index: 1;
}

canvas {
    z-index: 0;
}