在Chrome和Firefox上,如果我在标记上应用文本修饰:下划线,默认情况下,下划线不适用于伪元素.但在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;
}Run Code Online (Sandbox Code Playgroud)
<a href="#" id="underline">underline</a>
<br>
<a href="#" id="color">color</a>
<br>
<a href="#" id="span"><span>with span</span></a>Run Code Online (Sandbox Code Playgroud)