javascript 我可以禁用与画布的每个鼠标交互以与底层对象交互吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4777634/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I disable every Mouse Interaction with a canvas to interact with underlying Objects?
提问by rassoh
Let's say I have a graphical effect that I want to be overlaying HTML-Text. This Element shouldn't interfere with the usability of the site, it wouldn't have any interactive purpose. Is it possible to disable all Mouse Interaction on a certain html-object, for example on a canvas, so that I could still interact (klick on links, select text, ...) with the underlying objects?
假设我有一个图形效果,我想覆盖 HTML 文本。这个元素不应该干扰网站的可用性,它不会有任何交互目的。是否可以禁用某个 html 对象上的所有鼠标交互,例如在画布上,以便我仍然可以与底层对象交互(点击链接,选择文本,...)?
that would be great!
那很好啊!
回答by Phrogz
Using the pointer-events:noneCSS property(implemented first in SVG, on its way to HTML) allows you to turn off hit detection for an element.
使用pointer-events:noneCSS 属性(首先在 SVG 中实现,在它的方式到 HTML 中)允许您关闭元素的命中检测。
This is non-standard as of this writing and only supported in a subset of browsers. (Firefox and Safari/Chrome, but not Opera or IE.) Other than this, there is no way to do this.
在撰写本文时,这是非标准的,仅在部分浏览器中受支持。(Firefox 和 Safari/Chrome,但不是 Opera 或 IE。)除此之外,别无他法。
Here's the in-progress CSS3 referencefor this property.
这是此属性的正在进行的 CSS3 参考。
See also this question: CSS pointer-eventsproperty alternative for IE.
另请参阅此问题:IE 的CSSpointer-events属性替代方案。

