html - 如何删除聚焦按钮文本周围的白色虚线边框

标签 html css firefox

我需要,但不能,删除焦点按钮文本周围的白色虚线边框。

在阅读了关于“删除白色边框(尤其是 Dotted border around link? 和内部链接)”的文章后,我尝试了几种禁用轮廓的解决方案,例如 "outline: 0;outline: none; ,是否使用 !important

但没有任何方法可以去除聚焦按钮文本周围的白色虚线边框。 这是我最简单的测试页面代码。我无法显示屏幕截图,因为它会移除按钮的焦点。

button {
  font-size: 87.5%;
  font-family: "ubuntu", Sans-serif;
  padding: 0 16px;
  min-width: 64px;
  height: 36px;
  cursor: pointer;
  background-color: royalblue;
  color: white;
  border: 0;
}

button:focus,
button:active {
  outline: none;
  outline: 0;
  outline: none !important;
  outline: 0 !important;
}
<button type="button">TEST</button>

在 Ubuntu 18.04 (Bionic Beaver) 上使用 Firefox 67.0.3,此页面仍然显示聚焦按钮文本周围的白色虚线边框,我想将其删除(我将用我自己的方法显示焦点) .

最佳答案

这些样式在 UA 级别声明,因此每个浏览器都有自己的实现(在 Firefox 的情况下,针对它们的伪元素)。

在 Firefox 中,您可以使用 ::-moz-focus-inner 伪元素:

button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner {
    border: none;
}  

关于html - 如何删除聚焦按钮文本周围的白色虚线边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56725719/

相关文章:

javascript - Firefox 中半透明矩形的 SVG 网格

javascript - 在 Firefox 中更改 window.location.href 以响应 onunload 事件

java - 使用jsoup从 "a"inside "span"inside "class"提取属性用于体育软件

html - 垂直对齐带有阴影框和仅顶部 Angular 的图标的文本

html - 为什么这个 p 背景上似乎有填充?

css - 对齐文本后使用哪种样式显示图像

html - Firefox15.0.1 设计不兼容问题

javascript - 在 iframe 前面放置 SVG 而不是 PNG

javascript - 为什么 Bootstrap 导航栏中没有跟踪我的链接

javascript - 带 JavaScript 的单选按钮