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

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

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


当前回答

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

其他回答

正如其他人指出的那样,你似乎无法覆盖嵌套的文本装饰样式……但是你可以改变文字装饰颜色。

作为一个hack,我把颜色改为透明:

    text-decoration-color: transparent;

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

更新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 >

将以下HTML代码放在 <身体>标记:

<STYLE>A {text-decoration: none;

设置文本装饰:none;对于锚标记。

示例HTML。

<body>
    <ul class="nav-tabs">
        <li><a href="#"><i class="fas fa-th"></i>Business</a></li>
        <li><a href="#"><i class="fas fa-th"></i>Expertise</a></li>
        <li><a href="#"><i class="fas fa-th"></i>Quality</a></li>
    </ul>
</body>

CSS例子:

.nav-tabs li a{
  text-decoration: none;
}