[英]How can I have mouse events received by an HTML element with lower z-index?
I'm coding a checker game in JavaScript/JQuery. 我正在用JavaScript / JQuery编写一个检查游戏。 I have the following issue: I display the yellow arrows using a canvas that covers the entire screen and has z-index: 1. The checkers are z-index: 0.
我有以下问题:我使用覆盖整个屏幕并具有z-index的画布显示黄色箭头:1.跳棋的z-index:0。
I would like to add the possibility to drag and drop checkers. 我想添加拖放检查器的可能性。 I want to use the JQuery's draggable widget to make every checker draggable.
我想使用JQuery的可拖动小部件来使每个检查器可拖动。 However, since the canvas has a higher z-index than the checkers, the latter won't receive the mouse events.
但是,由于画布的z-index值高于检查器,因此检查器不会接收到鼠标事件。
How can I have the checkers received the mouse events despite having a lower z-index? 尽管Z索引较低,我如何使检查器收到鼠标事件?
if you don't need mouseevents for your canvas, give pointer-events:none;
如果您不需要画布的mouseevents,请指定
pointer-events:none;
a try. 尝试一下。 ( Relevant SO Question )
( 相关的SO问题 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.