Html 如何删除html中点击元素周围的虚线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13195081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:41:07  来源:igfitidea点击:

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

htmlcss

提问by hguser

I found that if there is a alink in the page which does not link to a new page,then when user click it,there will be a dotted line around the element,it will only disappear when user click anything else in the page,how to remove this?

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

Example:

例子:

enter image description here

在此处输入图片说明

Note the dotted line around the element Section 2.

注意元素周围的虚线Section 2

回答by Sowmya

Use outline:noneto anchor tag class

使用outline:none到锚标记类

回答by Mark

Like @Lo Juego said, read the article

就像@Lo Juego 说的,阅读文章

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

回答by Lo Juego

a {
    outline: 0;
  }

But read this before change it:

但在更改它之前阅读此内容:

removing-the-dotted-outline

去除虚线轮廓

回答by Akash

Try with !importantin css.

尝试使用!importantin css

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

回答by OldTrain

To remove all doted outline, including those in bootstrapthemes.

删除所有虚线轮廓,包括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;
}

Note: You should add link href for bootstrap css before the main css, so bootstrap doesn't override your style.

注意:您应该在主 css 之前为 bootstrap css 添加链接 href,这样 bootstrap 不会覆盖您的样式。

回答by chankruze

Removing outlinewill harm accessibility of a website.Therefore i just leave that there but make it invisible.

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

a {
   outline: transparent;
}

回答by Andrew

In my case it was a button, and apparently, with buttons, this is only a problem in Firefox. Solution found here:

就我而言,它是一个按钮,显然,对于按钮,这只是 Firefox 中的一个问题。在这里找到的解决方案:

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

回答by loyola

Its simple try below code --

它的简单尝试下面的代码 -

a{
outline: medium none !important;
}

If happy cheers! Good day

如果快乐欢呼!再会