通过绝对定位的元素传递鼠标事件 [英] Pass mouse events through absolutely-positioned element
问题描述
现在,绝对定位的元素上的事件打到它并冒泡到它的父母,但我希望它对这些鼠标事件透明,并将它们转发到它背后的任何东西。我应该如何实现?
pointer-events:none;
是一个css属性,使事件通过一个DOM元素,并使事件发生在元素下面。
查看详情: https: //developer.mozilla.org/en/css/pointer-events
不支持IE 11;所有其他供应商在很长一段时间后都支持(12/16年度的全球支持约为92%): http ://caniuse.com/#feat=pointer-events (感谢@Sidnicious提供评论中的链接)
I'm attempting to capture mouse events on an element with another absolutely-positioned element on top of it.
Right now, events on the absolutely-positioned element hit it and bubble up to its parent, but I want it to be "transparent" to these mouse events and forward them on to whatever is behind it. How should I implement this?
pointer-events:none;
Is a css-property that makes events "pass through" an DOM-element and makes the event occur on the element "below".
See for details: https://developer.mozilla.org/en/css/pointer-events
It not supported up to IE 11; all other vendors support it since quite some time (global support was ~92% in 12/'16): http://caniuse.com/#feat=pointer-events (thanks to @Sidnicious for providing the link in the comments)
这篇关于通过绝对定位的元素传递鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!