【问题标题】:Firefox adding an unwanted border on hover, active and focus statesFirefox 在悬停、活动和焦点状态上添加了不需要的边框
【发布时间】:2016-02-03 01:52:41
【问题描述】:

http://codepen.io/thatgibbyguy/pen/dGYEjE 处的此错误示例。

我正在努力解决除默认状态之外的所有状态的 Firefox 中的错误。我查看了这两个链接,但没有找到解决方案(Firefox outline around box-shadow on hoverCSS - Unwanted Border-Bottom)。

发生在悬停/聚焦/激活时,Firefox 要么在按钮底部周围绘制边框,要么将框阴影偏移一个像素并创建轮廓外观。

守则

<a class="lm-button lm-button--primary">Primary Button</a>

.lm-button, .lm-button--primary, .lm-button--secondary {
  display: inline-block;
  padding: .7em 1.25em .4em;
  font-family: arial;
  line-height: 1em;
  text-align: center;
  border-radius: 8px;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: all 100ms ease-out, transform 75ms ease, background 300ms ease-out;
}
.lm-button:focus, .lm-button--primary:focus, .lm-button--secondary:focus, .lm-button:active, .lm-button--primary:active, .lm-button--secondary:active {
  transform: translateY(0) scale(0.95);
}

.lm-button {
  color: #fff;
  background: #57554f;
  border: 1px solid #57554f;
  border-bottom: 0 none;
  box-shadow: 0 0.2em 0 #2f2e2b;
  margin-right: .5em;
}
.lm-button:hover {
  color: #fff;
  background: #64625b;
  box-shadow: 0 0.25em 0.05em #2f2e2b;
  transform: translateY(0) scale(1.025);
}
.lm-button:focus, .lm-button:active {
  color: #fff;
  border: 1px solid #57554f;
  background: #4a4843;
  border-bottom: 1px solid #4a4843;
  box-shadow: 0 0.25em 0 #4a4843, 0 0.15em 0.15em #1c1c1a inset;
}

我被这种行为难住了,正在寻找解决方案。

【问题讨论】:

  • 仍然无法解决问题,但朝着正确方向迈出的一步是移除按钮底部的框阴影。
  • 实际问题在您的transform 属性中。是 scale(x, y),你有 scale(1.025),改成 scaleX(1.025);修复它。这是修改后的笔。 codepen.io/anon/pen/vLNoRr
  • 几乎!它仍然在底部边界半径处留下少量白色残留物。如果你点击底部,更容易看到。
  • 那不是你的:hover 声明,而是你的:active。我正在回答您关于悬停时会发生什么,firefox 要么在按钮底部绘制边框...
  • 很奇怪,我明白你指的是什么。

标签: css firefox


【解决方案1】:

我认为这不是问题。这可能是基于浏览器的可访问性。

你可以试试:

selector::-moz-focus-inner {
  border: 0 !important;
}

selector:focus, selector:hover, selector:active {
   outline: 0 !important;
}

【讨论】:

  • 不幸的是,这并不能解决问题。感谢您的意见!
猜你喜欢
  • 2012-04-28
  • 2016-10-17
  • 2019-09-26
  • 1970-01-01
  • 2014-04-17
  • 1970-01-01
  • 1970-01-01
  • 2014-02-08
  • 1970-01-01
相关资源
最近更新 更多