Firefox adding an unwanted border on hover, active and focus states

时间:2015-12-14 18:04:35

标签: css css3 firefox

Example of this bug at http://codepen.io/thatgibbyguy/pen/dGYEjE.

I'm struggling with a bug in firefox on all states but the default state. I've looked at these two links but have not found a solution (Firefox outline around box-shadow on hover , CSS - Unwanted Border-Bottom).

What happens is on hover/focus/active, firefox is either drawing a border around the bottom of the button, or it is offsetting the box-shadow by one pixel and creating the appearance of an outline.

The Code

<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;
}

I'm stumped by this behavior and looking for solutions.

1 个答案:

答案 0 :(得分:0)

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

您可以尝试:

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

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