我可以让Firefox不显示丑陋的点状焦点轮廓的链接:
a:focus {
outline: none;
}
但我怎么能这样做<按钮>标签以及?当我这样做的时候:
button:focus {
outline: none;
}
当我点击它们时,按钮仍然有虚线焦点轮廓。
(是的,我知道这是一个可用性问题,但我想提供我自己的重点提示,这是适合于设计,而不是丑陋的灰点)
我可以让Firefox不显示丑陋的点状焦点轮廓的链接:
a:focus {
outline: none;
}
但我怎么能这样做<按钮>标签以及?当我这样做的时候:
button:focus {
outline: none;
}
当我点击它们时,按钮仍然有虚线焦点轮廓。
(是的,我知道这是一个可用性问题,但我想提供我自己的重点提示,这是适合于设计,而不是丑陋的灰点)
当前回答
使用此代码在Firefox 46和Chrome 49上测试。
input:focus, textarea:focus, button:focus {
outline: none !important;
}
之前(白点可见)
之后(白点看不见)
如果你想只应用在几个输入字段,按钮等。使用更具体的代码。
input[type=text] {
outline: none !important;
}
其他回答
在Firefox中使用CSS无法删除这些点状焦点。
如果你可以访问你的web应用程序工作的计算机,在Firefox中进入about:config并设置browser.display。Focus_ring_width为0。然后Firefox将不会显示任何虚线边界。
下面的错误解释了主题:https://bugzilla.mozilla.org/show_bug.cgi?id=74225
网络上有很多解决方案,其中很多都是有效的,但为了做到这一点,你可以使用以下方法:
::-moz-focus-inner, :active, :focus {
outline:none;
border:0;
-moz-outline-style: none;
}
这只是增加了一点额外的安全&密封交易!
【更新】这个解决方案不再有效。对我有效的解决方案是https://stackoverflow.com/a/3844452/925560
标记为正确的答案在Firefox 24.0中无法使用。
为了移除Firefox在按钮和锚标记上的虚线轮廓,我添加了下面的代码:
a:focus, a:active,
button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner,
select::-moz-focus-inner,
input[type="file"] > input[type="button"]::-moz-focus-inner {
border: 0;
outline : 0;
}
我在这里找到了解决方案:http://aghoshb.com/articles/css-how-to-remove-firefoxs-dotted-outline-on-buttons-and-anchor-tags.html
button::-moz-focus-inner { border: 0; }
Where button可以是你想要禁用行为的任何CSS选择器。
不需要定义选择器。
:focus {outline:none;}
::-moz-focus-inner {border:0;}
然而,这违反了W3C的可访问性最佳实践。大纲是用来帮助那些用键盘导航的人。
https://www.w3.org/TR/WCAG20-TECHS/F78.html#F78-examples