Javascript 是否可以将 div 的孩子设置为 pointer-events: none 有指针事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11920429/
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
Is it possible for the child of a div set to pointer-events: none to have pointer events?
提问by fancy
Is it possible for the child of a div set to pointer-events: none to have pointer events?
是否可以将 div 的孩子设置为 pointer-events: none 有指针事件?
I need the div that holds another div to allow pointer events to pass through, but for the div itself to still have events.
我需要持有另一个 div 的 div 以允许指针事件通过,但 div 本身仍然有事件。
Is this possible?
这可能吗?
回答by Brandon
Yes, it's possible, and you basically just described how. Disable it for the parent and enable it for the child:
是的,这是可能的,你基本上只是描述了如何。为父母禁用它并为孩子启用它:
? CSS:
? CSS:
.parent {
pointer-events:none;
}
.child {
pointer-events:all;
}
HTML:
HTML:
<div class="parent">
<a href="#">Parent</a>
<div class="child">
<a href="#">Child</a>
</div>
?</div>?????????????????????????????????????????