简体   繁体   English

如何使元素对点击透明但仍然可见?

[英]How to make an element transparent to clicks but still visible?

I'm interested in putting an inset box shadow on something like an iframe.我有兴趣在 iframe 之类的东西上放置一个嵌入框阴影。 While the strategy of overlaying a div over the iframe gives the expected visual display, the div subsequently blocks clicks on the iframe itself.虽然将 div 覆盖在 iframe 上的策略提供了预期的视觉显示,但 div 随后会阻止对 iframe 本身的点击。

Sample: http://jsfiddle.net/YqXPg/样品: http://jsfiddle.net/YqXPg/

So is there a way to pull off the inset shadow as a "framing" effect?那么有没有办法将嵌入阴影作为“框架”效果拉出来?

Yes, there's pointer-events: none .是的,有pointer-events: none

See: http://jsfiddle.net/YqXPg/3/见: http://jsfiddle.net/YqXPg/3/

A version that makes the overlay more obvious: http://jsfiddle.net/YqXPg/4/使覆盖更明显的版本: http://jsfiddle.net/YqXPg/4/

Note that this property doesn't work with IE, but if I remember correctly, IE will allow you to click through the transparent parts of the overlay div anyway.请注意,此属性不适用于 IE,但如果我没记错的话,IE 将允许您单击覆盖div的透明部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM