css - 文字装饰 :none; doesn't work for a simple example

标签 css html text-decorations

我很好奇为什么 “不应该加下划线” 单词在下面的代码中仍然带有下划线:

<html>
<head>
<style type="text/css">
.badge1-link { text-decoration: none; }
.badge1 { text-decoration: underline; }

.badge2-link {text-decoration: underline;}
.badge2 {text-decoration: none;}

</style> 
</head>
<body>
<a href="#" class="badge1-link"><span class="badge1">Underlined</span> | not underlined</a>
<br/>
<a href="#" class="badge2-link"><span class="badge2"> Should not be underlined</span> | Underlined</a>
</body>
</html>

最佳答案

一旦给 anchor 标签加上下划线,就不能将其部分删除,就像您为 badge2 所建议的那样

请参阅此链接:Remove stubborn underline from link .接受的答案有一些评论是相同的。

您的问题的解决方案是从 anchor 标记中删除下划线,然后像对 badge1

那样添加部分下划线

关于css - 文字装饰 :none; doesn't work for a simple example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11986948/

相关文章:

css - 具有 3 个常规列和 1 个垂直旋转的四列 div

html - CSS 中左浮动 div 的负右边距有什么用?

javascript - 导航菜单列表(子菜单)下拉列表在 reactjs 中不起作用

javascript - 如何在按钮单击时聚焦下一个文本区域

javascript - 通过 ReactJS 使用 MaterializeCSS 显示 HTML 元素

html - 在单个元素上继承多个文本装饰

html - Font Awesome 图标重复

javascript - 在react.js中渲染时如何移除树的根

html - 文字装饰 : underline not applying with inline-block span elements

text-decorations - 从链接中删除文本装饰