javascript 禁用链接突出显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5233316/
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
Disable link highlighting
提问by Per Magnusson
Hey, im just wondering if it is possible to disable the "highlighting" you get when you click on a link. I want my link to behave as an image. In other words i dont want the highlighting box appear on click.
嘿,我只是想知道是否可以禁用单击链接时获得的“突出显示”。我希望我的链接表现得像一个图像。换句话说,我不希望突出显示框出现在点击。
回答by Thai
It can be done using CSS, by setting the outlineof the link on focus:
可以使用 CSS 完成,通过将outline链接设置为焦点:
a.image-link:focus { outline: 0; }
But you need to remember to always define an alternative style(such as changing color, or changing image background, to make the user know that it's being clicked). Else, DON'T DO IT!.
但是您需要记住始终定义替代样式(例如更改颜色或更改图像背景,以使用户知道它正在被单击)。否则,不要这样做!.
People who use keyboard to navigate rely on this outline to know which link they are focusing.
使用键盘导航的人依靠这个大纲来知道他们关注哪个链接。
回答by wsanville
I assume you're looking to turn off the outline that browsers put around links when they're clicked. That would be:
我假设您希望关闭浏览器在点击链接时放置在链接周围的轮廓。那将是:
a { outline: none; }
回答by bbsimonbb
You also need to manage -webkit-tap-highlight-color, and you need to provide alternative styles, notably for users who navigate with the tab key and rely on highlighting of some sort to see where they are. So that gives...
您还需要管理 -webkit-tap-highlight-color,并且您需要提供替代样式,特别是对于使用 Tab 键导航并依靠某种突出显示来查看它们所在位置的用户。所以这给...
<style>
a,a:hover,a:click, a:visited{
border:none;
outline:none;
text-decoration:none;
color:inherit;
-webkit-tap-highlight-color: white;
}
</style>
回答by FatherStorm
<style>
a,a:hover,a:click, a:visited{
border:none;
outline:none;
text-decoration:none;
color:inherit;
}
</style>

