无法从链接中删除下划线

时间:2015-12-16 17:33:46

标签: html css

我在锚标签中有一个简单的div,我试图从链接中删除蓝色下划线。

.removelinkdefault {
    color: black;
    text-decoration: none !important;
}
<a href="/user/reillylawless23"><div class="removelinkdefault">Reilly Lawless</div></a>

我见过的所有文档都说使用text-decoration: none;,但它似乎没有起作用:

enter image description here

我做错了什么以及如何解决?

3 个答案:

答案 0 :(得分:6)

尝试将class="removelinkdefault"添加到链接(a)而不是div

.removelinkdefault {
    color: black;
    text-decoration: none;
}
<a href="/user/reillylawless23" class="removelinkdefault"><div>Reilly Lawless</div></a>

此外,现在您不需要!important

答案 1 :(得分:3)

从锚元素而不是div

中删除下划线
a {
  text-decoration: none;
}

答案 2 :(得分:0)

链接是<a>标记,而不是<div>

&#13;
&#13;
a {
    color: black;
    text-decoration: none !important;
}
&#13;
<a href="/user/reillylawless23"><div class="removelinkdefault">Reilly Lawless</div></a>
&#13;
&#13;
&#13;

相关问题