是否可以让鼠标事件通过画布层? [英] Is it possible to let mouse events pass through a canvas layer?
问题描述
我有一个图像网格,并在其顶部有一个画布层,一旦用户将鼠标悬停在网格上的缩略图上,我想在canvas标签上做一些动画,所以我想知道是否可以让鼠标事件通过画布层吗?
在画布上尝试以下CSS属性:
pointer-events:无
http://dev.w3.org/csswg/css3-ui/#pointer-events
旨在防止该元素完全接收任何鼠标事件.Mozilla似乎相信该事件会像您希望的那样传递到其背后的元素中.
https://developer.mozilla.org/en/CSS/pointer-events >
IE和Opera中可能不支持此功能,因此您可能必须在这些浏览器中禁用动画.
I have a grid of images and a canvas layer on top of it, I would like to do some animations on the canvas tag once the user rolls over a thumbnail image from the grid, so I wonder if is possible to let mouse events pass through the canvas layer?
Try this css property on your canvas:
pointer-events: none
http://dev.w3.org/csswg/css3-ui/#pointer-events
It is intended to prevent the element from receiving any mouse events at all. Mozilla seems to believe that the event will pass through to elements behind it like you are hoping.
https://developer.mozilla.org/en/CSS/pointer-events
It looks like this may not be supported in IE and Opera, so you might have to disable your animation in those browsers.
这篇关于是否可以让鼠标事件通过画布层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!