我试图有一个链接显示在白色,没有下划线。文本颜色正确地显示为白色,但蓝色下划线顽固地坚持。我尝试了文字装饰:没有;文字装饰:none !在CSS中删除链接下划线。既不工作。

.boxhead .otherPage { 颜色:# FFFFFF; 文字修饰:没有; } < div class = "表头栏”> < h2 > <span class="thisPage">当前页面</span> <a href="myLink"><span class="otherPage">Different Page</span></a> . < / h2 > < / div >

如何从链接中删除蓝色下划线?


当前回答

在我的重置,CSS通常是:

a {
  cursor: pointer;
  text-decoration: none !important;
  color: inherit;
} 

其他回答

没有一个答案对我有用。在我的案例中,有一个标准

a:-webkit-any-link {
    text-decoration: underline;

在我的代码中。基本上不管链接是什么,文本颜色都是蓝色,链接保持原样。

所以我在header的末尾添加了这样的代码:

<head>
  </style>
    a:-webkit-any-link {
      text-decoration: none;
    }
  </style>
</head>

问题已经解决了。

如果text-decoration: none或border: 0不起作用,请尝试在HTML内容中应用内联样式。

覆盖嵌套的文本装饰样式。

寻找任何::before或::after选择器,并将none显示为任何文本装饰,border-bottom等,或将属性(unset)重置为任何文本颜色属性,如:text-decoration-color, background-color等。

.boxhead .otherPage {
    color: #FFFFFF;
}

a.boxhead .otherPage:before {
    background-color: unset;
}

or

a.boxhead .otherPage:before {
    background-color: unset !important;
}

更新2023

这个问题已经有点老了。在CSS中,你可以用all: unset删除标签的所有特性。

.w { 字体大小:1.4快速眼动; } .w .s2 a, .w .s3 a { :设置; } .w .s3 a { 颜色:红色; } < div class = " w " > < div class = " s1”> <a href="">link a </a> . < / div > < div class = " s2”> <a href="">link B</a> . < / div > s3 < div class = " " > <a href="">link C</a> < / div > < / div >

下面是一个ASP的例子。NET Web Forms LinkButton控件:

 <asp:LinkButton ID="lbmmr1" runat="server" ForeColor="Blue" />

后台代码:

 lbmmr1.Attributes.Add("style", "text-decoration: none;")