【发布时间】:2015-01-17 01:32:30
【问题描述】:
在 Chrome 和 Firefox 上,如果我在标签上应用 text-decoration:underline,默认情况下下划线不适用于伪元素。 但在 IE 上确实如此,我无法删除它。 我希望链接带有下划线,而不是伪元素。
如果我在里面添加一个跨度并在上面加上下划线,它会起作用,但我想知道它是否可以在没有额外标记的情况下制作。
a{
padding-left: 9px;
position:relative;
display:inline-block;
}
a:before{
content:'\203A\00a0';
position:absolute;
top:0;
left:0;
display: inline-block;
}
#underline{
text-decoration: none;
}
#underline:hover{
text-decoration:underline;
}
/* special for IE */
#underline:hover:before
{
text-decoration:none !important; /* does nothing ! */
}
#color{
color:green;
}
#color:hover{
color:red;
}
#color:hover:before{
color:green; /* work ! */
}
#span{
text-decoration: none;
}
#span:hover span{
text-decoration: underline;
}
<a href="#" id="underline">underline</a>
<br>
<a href="#" id="color">color</a>
<br>
<a href="#" id="span"><span>with span</span></a>
【问题讨论】:
标签: html css internet-explorer