在悬停时添加大纲

时间:2014-08-14 13:20:29

标签: css hover outline

我正在创建一个&#34;回到顶部&#34;我网站的按钮。当我将鼠标悬停在<a>上时,会出现蓝色轮廓,但我无法弄清楚如何摆脱它。我要离开的是什么?

这是它在常规状态下的样子:
enter image description here

悬停时:
enter image description here

HTML:

<p id="back-top">
    <a href="#top"><span></span>Back to Top</a>
</p>

CSS:

#back-top {
  position: fixed;
  bottom: 30px;
  right: 100px;
}
#back-top a {
  width: 70px;
  display: block;
  text-align: center;
  font: 11px/100% Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  text-decoration: none;
  color: #bbb;
  /* transition */
  -webkit-transition: 1s;
  -moz-transition: 1s;
  transition: 1s;
}
#back-top a:hover {
  color: #004276;
  border: none !important;
  outline: none !important;
}
#back-top a:hover span {
  background-color: #777;
  outline: none !important;
  border: none !important;
}
#back-top a span {
  width: 70px;
  height: 50px;
  display: block;
  margin-bottom: 7px;
  background: url("../images/BackToTop.png") no-repeat center center;
  /* transition */
  -webkit-transition: 1s;
  -moz-transition: 1s;
  transition: 1s;
}

1 个答案:

答案 0 :(得分:1)

您的问题是您在悬停时为SPAN添加了背景颜色。

因为你的背景图像上面有一个边框半径, 然后背景颜色显示在它下面。

修复它只是从你的css中删除以下内容:

#back-top a:hover span {
  background-color: #777;  /* REMOVE THIS LINE */
  outline: none !important;
  border: none !important;
}
祝你好运!