css - 从链接中删除蓝色下划线

标签 css hyperlink underline

我试图让一个链接显示为白色,没有下划线。文本颜色正确显示为白色,但蓝色下划线顽固地存在。我在 CSS 中尝试了 text-decoration: none;text-decoration: none !important; 来删除链接下划线。都没有用。

.boxhead .otherPage {
  color: #FFFFFF;
  text-decoration: none;
}
<div class="boxhead">
  <h2>
    <span class="thisPage">Current Page</span>
    <a href="myLink"><span class="otherPage">Different Page</span></a>
  </h2>
</div>

如何去除链接中的蓝色下划线?

最佳答案

您没有将 text-decoration: none; 应用于 anchor (.boxhead a),而是应用于跨度元素 (.boxhead ).

试试这个:

.boxhead a {
    color: #FFFFFF;
    text-decoration: none;
}

关于css - 从链接中删除蓝色下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2789703/

相关文章:

javascript - ReactJS 和 Material UI makeStyles/useStyles 问题

vba - 如何使用超链接(或通过将宏分配给超链接)在 Excel 中扩展组

css - 如何在这个纯 HTML/CSS 幻灯片中添加指向每个图像的链接?

css - 如何格式化最近点击的链接

css - 如何设计嵌入在电子邮件中的重力形式?

html - 仅覆盖父 div 的叠加层

c# - Visual Studio 2008用红色强调非错误代码

css - 如何获取按钮值中的 sqrt 符号?

css - 线性渐变边框底部不起作用