SVG无法识别指针事件:无 [英] SVG not recognising pointer-events:none
问题描述
我有一个透明背景图像集的顶层,并希望所有的指针事件被忽略。所以原来我有这个设置与< div style =pointer-events>< / div>
这工作很好,但后来我发现IE doesn不支持这个。
I have a top layer with a transparent background image set and would like all pointer events to be ignored. So originally I had this set up with <div style="pointer-events"></div>
which worked great, but then I find out that IE doesn't support this.
进一步阅读我发现几个地方说,IE支持< svg>
with pointer-events:none
,但我不能得到它的工作(我从来没有使用SVG标签,所以我可以做这个错误)。
Further reading I find several places that says IE does support <svg>
with pointer-events:none
, but I can't get it to work (I've never used SVG tags before so I could be doing this all wrong).
请看这个非常简化的小提琴,我希望实现。 http://jsfiddle.net/AGVTM/
Please see this very simplified fiddle of what I'm hoping to achieve. http://jsfiddle.net/AGVTM/
推荐答案
< svg>
元素不支持 pointer-events:none
。这背后的原因是这是一个可能的安全漏洞,你可以覆盖一个带有SVG的Facebook Like按钮,并允许点击通过,如在这个例子 http://jsfiddle.net/rVxTn/
The root (top most) <svg>
element will not support pointer-events: none
. The reason behind this is that it's a possible security exploit, you could cover a Facebook Like button with an SVG and let clicks go through as in this example http://jsfiddle.net/rVxTn/
如果SVG元素不是root,则点击应该通过。此示例应适用于IE9(未测试)
If the SVG element is not root then clicks should go through. This example should work on IE9 (untested)
但是,这不能解决你的问题,因为你不能把HTML元素放在SVG元素内。
However, this doesn't solve your problem, because you cant put HTML elements inside the SVG element.
我之前遇到过这个问题多次,我不得不以不同的方式解决它。我建议您在实际问题(以及可能的屏幕截图)中打开一个新问题,了解如何解决这个问题。
I've encountered this problem multiple times before, I've had to work around it in different ways. I'd suggest you to open a new question with the actual problem (and possibly screenshots) to see how this can be worked around.
这篇关于SVG无法识别指针事件:无的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!