【发布时间】:2013-12-22 16:10:38
【问题描述】:
是否可以通过 CSS 将 :before 伪元素添加到 A html 标签而不显示伪元素的下划线文本装饰?
在下面的标记中,在链接的左侧添加了一个“+”符号,鼠标悬停在该链接的左侧正确地加了下划线,但是即使 css 规则设置为“h3 a”,伪符号“+”也加了下划线:before:hover{ text-decoration:none; }"
<style>
h3 {
display:block;
margin:20px auto;
padding:6px;
width:85%;
text-align:left;
font: 21px 'lucida sans'; color:#444;
border-bottom:#ccc 1px solid;
}
h3 a{
margin:0; padding:8px 4px 0 0;
display:inline;
float:right;
width:auto;
text-decoration:none;
font: 14px 'lucida sans';
}
h3 a:hover{ text-decoration:underline; }
h3 a:before{ content: '+'; margin:0; padding: 4px; }
h3 a:hover:before{ text-decoration:none; }
</style>
<h3>My Title <a href="#">link</a></h3>
【问题讨论】:
-
对于任何愿意尝试的人......这里有一个 jsbin 可以玩:jsbin.com/oVOhoSej/1/edit。非常有趣的问题,因为我还没有找到解决这个问题的方法。
标签: html css pseudo-element