CSS 从特定锚标记中删除下划线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4150780/
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
removing underline from specific anchor tag
提问by TPR
why does following anchor tag has text underlined?
为什么以下锚标记的文本带有下划线?
<a class = "pagerLink" href = "#" >test</a>
.pagerLink{
background-color: #E4F5F8;
border:1px solid #C0DEED;
text-decoration:none;
}
回答by Frédéric Hamidi
Probably because another style block has better precedencethan your pagerLink
class. Try:
可能是因为另一个样式块比您的类具有更好的优先pagerLink
级。尝试:
.pagerLink {
background-color: #E4F5F8;
border: 1px solid #C0DEED;
text-decoration: none !important;
}
回答by Shyju
use text-decoration:none for a in your styles
在您的样式中使用 text-decoration:none
Ex:
前任:
<head>
<style>
.pagerLink
{
background-color: #E4F5F8;
border:1px solid #C0DEED;
}
.pagerLink a
{
text-decoration:none !important;
}
</style>
</head>
<body>
<div class="pagerLink">
<a href="somepage.aspx">test</a>
</div>
</body>
You can use firebug(a firefox plugin) to findout which style is being used for the element now and whether its being overwritten by some other style definition
您可以使用 firebug(一个 firefox 插件)来找出元素现在正在使用哪种样式以及它是否被其他样式定义覆盖
回答by Matt Styles
I cant yet leave comments and I respect this is an old question but be extremely careful when using !important in your declarations:
我还不能发表评论,我尊重这是一个老问题,但在您的声明中使用 !important 时要非常小心:
text-decoration: none !important;
text-decoration: none !important;
You'll probably get away with it in smaller projects but with any non-trivial project that involves collaboration from multiple sources this sort of thing can be incredibly annoying when it over-rides a property I need to set further down the line. Not only do I have to change this to make my fix stick but I also have to check that changing it does not break anything else, which it probably will.
您可能会在较小的项目中摆脱它,但是对于任何涉及来自多个来源的协作的非平凡项目,当它覆盖我需要进一步设置的属性时,这种事情可能会非常烦人。我不仅必须更改它以使我的修复坚持下去,而且我还必须检查更改它不会破坏其他任何东西,它可能会破坏。
Better is to refactor your declaration or restructure your code so that you dont need to use !important
and onlyfall back to !important
when you cant.
更好的是重构您的声明或重构您的代码,以便您不需要使用!important
并且仅!important
在您不能使用时才回退。
回答by THIMIRA
To remove underline you need to follow following style code snippet.
要删除下划线,您需要遵循以下样式代码片段。
.pagerLink{
background-color: #E4F5F8;
border:1px solid #C0DEED;
text-decoration:none !important;
}