我可以禁用与画布的所有鼠标交互以与底层对象交互吗?
假设我有一个图形效果,我想覆盖 HTML 文本。该元素不应干扰网站的可用性,它不会有任何交互目的。 是否可以禁用某个 html 对象(例如画布)上的所有鼠标交互,以便我仍然可以与底层对象交互(单击链接、选择文本等)?
那太好了!
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?
that would be great!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
pointer-events:none
CSS 属性 (首先在 SVG 中实现,随后又转向 HTML)允许您关闭元素的命中检测。截至撰写本文时,这是非标准的,仅在部分浏览器中受支持。 (Firefox 和 Safari/Chrome,但不包括 Opera 或 IE。)除此之外,没有办法做到这一点。
以下是此属性的正在进行的 CSS3 参考。
另请参阅此问题:CSS
pointer-events
IE 的属性替代。Using the
pointer-events:none
CSS property (implemented first in SVG, on its way to HTML) allows you to turn off hit detection for an element.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.
Here's the in-progress CSS3 reference for this property.
See also this question: CSS
pointer-events
property alternative for IE.