how to remove the dotted line around the clicked a element in html

我发现如果页面中有一个 a链接没有链接到一个新的页面,那么当用户点击它的时候,元素周围会有一条虚线,只有当用户点击页面中的任何东西的时候它才会消失,如何删除这个?

例如:

enter image description here

注意元素 Section 2周围的虚线。

109245 次浏览

使用 outline:none锚定标记类

a {
outline: 0;
}

但在改变它之前,请先阅读以下内容:

删除虚线轮廓

就像@Lo Juego 说的,读读这篇文章

a, a:active, a:focus {
outline: none;
}

删除所有虚线大纲,包括那些在 bootstrap主题。

a, a:active, a:focus,
button, button:focus, button:active,
.btn, .btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn.focus:active, .btn.active.focus {
outline: none;
outline: 0;
}


input::-moz-focus-inner {
border: 0;
}

注意: 您应该在主 css 之前为 bootstrap css 添加 link href, 这样引导程序就不会覆盖你的样式。

css中尝试使用 !important

a {
outline:none !important;
}
// it is `very important` that there is `no` `outline` for the `anchor` tag.  Thanks!

它的简单尝试如下代码-

a{
outline: medium none !important;
}

如果快乐干杯! 再见

删除 outline将损害网站的可访问性。因此,我只是留在那里,但使它不可见。

a {
outline: transparent;
}

在我的例子中,它是一个按钮,显然,对于按钮来说,这只是 Firefox 中的一个问题。解决方案发现 给你:

button::-moz-focus-inner {
border: 0;
}