css - 添加指针事件后光标重置为默认值 :none in Firefox

标签 css firefox mouse-cursor

关于 Firefox 中 CSS pointer-eventscursor 规则之间的 CSS 关系,我遇到了一个奇怪的行为。当我将元素的 cursor 设置为不同于 auto 的任何值时(假设它是 wait),光标的类型会相应地发生变化,如预期的那样.但是,当我还向同一元素添加 pointer-events: none 时,光标将重置为 auto。如果我使用 cursor: wait !important 也会发生同样的情况。完全相同的规则在 Chromium 和 IE (!) 中正常工作。

一开始我认为这可能是设置 pointer-events: none 时的预期行为,但根据 MDN关于 none 值的部分:

The element is never the target of mouse events; however, mouse events may target its descendant elements if those descendants have pointer-events set to some other value. In these circumstances, mouse events will trigger event listeners on this parent element as appropriate on their way to/from the descendant during the event capture/bubble phases.

似乎不会传播 Javascript 事件,而不是 CSS 事件。

问题是:有没有办法在 Firefox 的同一个元素上同时使用 pointer-events: nonecursor: wait ?另外,关于上述摘录的 Javascript/CSS 事件的解释,我是否正确?

如果重要的话,我在 Ubuntu 64 位上使用 Firefox 31

这是一个 fiddle .在这种情况下,我动态添加规则,但仅使用 CSS 时也会发生同样的情况。我所说的场景是 Change cursor to wait --> Disable pointer events

最佳答案

原来你必须在父元素上设置光标。

在一个元素上设置两种样式或在嵌套元素上设置光标会将光标重置为默认指针。

<div class="cursor-wait">
    <a href="#">wait</a>
    <div class="no-pointer-events">
        <a href="#">wait > no events</a><!-- works here -->
    </div>
</div>

参见 Fiddle了解详情。

关于css - 添加指针事件后光标重置为默认值 :none in Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25563725/

相关文章:

ios - iPhone 6 和 6 Plus 响应断点

带有 CSS 翻译的 jQuery mousemove

c# - 以编程方式更改 Windows 中的光标速度

java - JScrollPane 中的滚动条在 JTables 上不起作用

css - 使用纯 CSS 更改窗口光标

html - 为 css 图像获取 alt 的解决方法

firefox - 为什么VSCode外部链接打不开,导致firefox崩溃

javascript - Mozilla Firefox 中的 CSS/JS 问题

javascript - Webkit/Safari/火狐/API : Can I programmatically read/extract multiple tabs' URLs?

css - 在 Ionic 框架中右对齐列表项内容