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

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

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


当前回答

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

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

    text-decoration-color: transparent;

其他回答

没有看到那页纸,很难推测。

但听起来你可能有一个边界底部:1px纯蓝色;被应用。也许可以添加border: none;。文字装饰:没有!重要的是正确的;有可能你有另一种样式仍然覆盖这个CSS。

这就是使用Firefox Web开发工具栏非常棒的地方。你可以在那里编辑CSS,看看它是否工作,至少对Firefox是这样。它在CSS→编辑CSS。

就我而言,我使用的HTML格式很差。链接在<u>标签内,而不是<ul>标签内。

您错过了锚标记的文本修饰:none。所以代码应该如下所示。

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

文本装饰的更多标准属性

有时您会看到框影,而不是文本下划线。

试试这个(使用任何适合你的CSS选择器):

a:hover, a:visited, a:link, a:active {

    text-decoration: none!important;

    -webkit-box-shadow: none!important;
    box-shadow: none!important;
}

设置文本装饰: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;
}