如何从Firefox中删除对焦环,主窗口的正确选择器是什么?

How to remove focus rings from Firefox, what is the correct selector for the main window?

提问人:Jeff 提问时间:3/25/2017 最后编辑:CommunityJeff 更新时间:3/26/2017 访问量:1244

问:

编辑:对焦环是由 Grab And Drag 插件引起的。请参阅下面的答案进行修复。

每当我点击网页主体的任何部分时,Firefox(Pale Moon 27.2.1)都会在浏览器窗口的周边放置焦点环(见截图)。它在每个网页上都这样做。

多年来,这个问题已经被问了一百万次,但似乎没有一个旧的解决方案已经奏效了。请参阅此处和此处

我可以告诉你一些有效和无效的事情:

“通配符”选择器通过以下声明删除了焦点环,但显然会破坏所有网站:

* {
    /* WORKS */
    color: transparent !important;
    text-shadow: 0 0 0 #000 !important;

    /* ALSO WORKS */
    border: 1px solid white !important;
    outline: 2px solid white !important;
    outline-offset: -1px !important;
}

这些选择器不起作用:

:focus
::-moz-focus-inner
:-moz-focusring
:active
:focus
::-moz-focus-outer

这些声明不起作用:

border: 0 !important;
border: none !important;
outline: 0 !important;
outline: none !important;
-moz-outline-style: /* NOPE */;

截图:

Reddit / Google in Firefox showing inner focus rings

我正在使用Stylish来设置上述规则的所有网页的样式()。我还使用了另一个时尚规则集,它看起来像这样,适用于其他所有内容:@-moz-document url-prefix( "http://" ), url-prefix( "https://")

:active, :focus, ::-moz-focus-inner {
    outline: 0 !important;
}

a:link, a:visited, a:hover, a:active {
    outline: 0 !important;
}

radio * {
    border-width: 0 1px 0 0 !important;
    border-style: dotted !important;
    border-color: transparent !important;
}
css firefox css-selectors 时尚 的苍白月

评论

0赞 Brock Adams 3/25/2017
这被标记为Firefox,但我在FF中没有看到问题(不打算安装Palemoon ATT)。..在第一个代码组中,尝试将 替换为 and/或 。*htmlbody
0赞 Jeff 3/25/2017
在您的帮助下,我回答了以下问题。如果您想将我的答案中的代码复制/粘贴到您自己的答案中,我会将您的答案标记为正确。
0赞 Brock Adams 3/26/2017
谢谢,但你已经有了答案,我不需要那么多代表。;)

答:

0赞 Jeff 3/25/2017 #1

这确实如此,尽管我仍然想知道Firefox正在“着色”什么?

编辑:对焦环是由抓取和拖动插件 >= v.3.2.* 引起的。对我来说,解决方法是使用 Grab And Drag v.3.1.9.1,当单击和拖动身体时,它不会在网页主体上显示任何焦点环。

@-moz-document regexp( "https?://.*" ) {
    html {
        /**
         * Remove focus rings that appear on the perimeter of the web page
         * body when placing cursor in any form field input, then clicking
         * anywhere in the body.
         *
         * This css rule breaks a lot of websites!
         *
         * - Works on html tag, but not body tag.
         * - Does not work with "outline: 0 !important;" or
         *   "border: 0 !important;"
         * - This declaration is not necessary:
         *   "text-shadow: 0 0 0 #000 !important;"
         */

        color: transparent !important;
    }
}