3
A
回答
4
你需要给:after
伪元素position:absolute;
,并给它margin
来接班。此外,锚点要求display:inline-block;
才能使:after
内容正确显示。
6
处理最简单的方法就是换一个span
围绕在每个链接的文字:
<a href="#"><span>test</span></a>
在:hover
只有span
给出text-decoration: underline
:
a:hover span {text-decoration: underline}
参见:http://jsfiddle.net/thirtydot/3N9vs/27/
类似的旧的问题:Cannot undo text-decoration for child-elements
也与此有关:CSS text-decoration property cannot be overridden by child element
+1
在我的答案中提到的文字装饰的传播适用于伪元素好吧,因为他们生成的盒子是'a'元素盒子的孩子。不过,不太清楚为什么Josh的解决方案可以在Chrome和Firefox中使用。 – BoltClock 2012-04-12 11:31:21
这没有任何区别,例如,IE9。 – thirtydot 2012-04-12 11:17:40
你说得对,似乎在Chrome和Firefox中工作,但不是IE。也许有没有一个完全基于CSS的解决方案,这个问题 – 2012-04-12 11:24:44
我不认为有这个问题。我想起了以前的这个问题:http://stackoverflow.com/questions/5434819/cannot-undo-text-decoration-for-child-elements – thirtydot 2012-04-12 11:25:28