如何删除下划线从名称悬停

我有这样的 html:

<legend class="green-color"><a name="section1">Section</a></legend>


legend.green-color{
color:green;
}

在我的情况下 Section看起来是绿色的,但是当我把鼠标指针放在它上面时,它看起来像一个 href,但是我希望它保持不变,没有下划线和改变颜色。

是否有可能在不改变 css 的情况下实现,或者在 css 改变最小的情况下实现?

或者可能与 jquery 有关?

244496 次浏览

试试这个:

legend.green-color a:hover{
text-decoration: none;
}

要保持颜色并防止链接上出现下划线:

legend.green-color a{
color:green;
text-decoration: none;
}

您可以使用 legend.green-color a:hover下的 CSS 来完成。

legend.green-color a:hover {
color:green;
text-decoration:none;
}

删除锚标记的文本装饰

<a name="Section 1" style="text-decoration : none">Section</a>

你可以为特定的链接分配一个 id 并添加 CSS。请参阅下面的步骤:

1. 添加您选择的 id (必须是唯一的名称; 只能以文本开始,不能以数字开始) :

<a href="/abc/xyz" id="smallLinkButton">def</a>
  1. 然后添加必要的 CSS,如下所示:

    #smallLinkButton:hover,active,visited{
    
    
    text-decoration: none;
    }
    

legend.green-color{
color:green !important;
}

react中你需要这样做

<Link to="/" style=\{\{ textDecoration: 'none' }}>
....
</Link>

或者如果在 react中使用 bootstrap,那么使用这个类

className="text-decoration-none"