【问题标题】:Click button under canvas in HTML单击 HTML 中画布下的按钮
【发布时间】:2016-01-12 11:31:33
【问题描述】:

我在 html 中有一个按钮。

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

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

是否可以让画布在鼠标点击时“不可见”?

【问题讨论】:

    标签: html canvas click


    【解决方案1】:

    在按钮和画布上尝试 z-index。

    button, canvas {
        position: relative;
    }
    
    button {
        z-index: 1;
    }
    
    canvas {
        z-index: 0;
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        也许用 z-index 试试?

        按钮: z-index: 1;

        画布: z-index: 0;

        【讨论】:

          【解决方案4】:

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

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

          【讨论】:

            猜你喜欢
            • 2019-08-09
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2022-08-18
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-02-04
            相关资源
            最近更新 更多