我可以让Firefox不显示丑陋的点状焦点轮廓的链接:
a:focus {
outline: none;
}
但我怎么能这样做<按钮>标签以及?当我这样做的时候:
button:focus {
outline: none;
}
当我点击它们时,按钮仍然有虚线焦点轮廓。
(是的,我知道这是一个可用性问题,但我想提供我自己的重点提示,这是适合于设计,而不是丑陋的灰点)
我可以让Firefox不显示丑陋的点状焦点轮廓的链接:
a:focus {
outline: none;
}
但我怎么能这样做<按钮>标签以及?当我这样做的时候:
button:focus {
outline: none;
}
当我点击它们时,按钮仍然有虚线焦点轮廓。
(是的,我知道这是一个可用性问题,但我想提供我自己的重点提示,这是适合于设计,而不是丑陋的灰点)
当前回答
如果你更喜欢使用CSS来摆脱虚线轮廓:
/*for FireFox*/
input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner
{
border : 0;
}
/*for IE8 and below */
input[type="submit"]:focus, input[type="button"]:focus
{
outline : none;
}
其他回答
button::-moz-focus-inner {
border: 0;
}
使用此代码在Firefox 46和Chrome 49上测试。
input:focus, textarea:focus, button:focus {
outline: none !important;
}
之前(白点可见)
之后(白点看不见)
如果你想只应用在几个输入字段,按钮等。使用更具体的代码。
input[type=text] {
outline: none !important;
}
在大多数情况下,如果不向CSS代码中添加重要的!,它将无法工作。
所以,别忘了加上!important
a, a:active, a:focus{
outline: none !important; /* Works in Firefox, Chrome, IE8 and above */
}
或任何其他代码:
button::-moz-focus-inner {
border: 0 !important;
}
网络上有很多解决方案,其中很多都是有效的,但为了做到这一点,你可以使用以下方法:
::-moz-focus-inner, :active, :focus {
outline:none;
border:0;
-moz-outline-style: none;
}
这只是增加了一点额外的安全&密封交易!
button::-moz-focus-inner { border: 0; }
Where button可以是你想要禁用行为的任何CSS选择器。