从锚内跨度上删除下划线 [英] Remove underline from span inside anchor
问题描述
我有这个HTML:
<ul>
<li>
<ul>
<li>
<a href="#"> <span> Test </span> Link </a>
</li>
</ul>
</li>
</ul>
这个CSS:
ul li ul li span {
text-decoration:none;
}
为什么锚点内的跨度仍带有下划线?
Why would the span inside the anchor still have underline?
换句话说:除以外,我将如何对所有带下划线的文本加下划线.谢谢
In other words: How would I get all the text underlined, except the SPAN. Thanks
推荐答案
您需要定位anchor tag
而不是span tag
,因此请使用此
You need to target the anchor tag
and not the span tag
so use this
ul li ul li a {
text-decoration:none;
}
原因:默认情况下,text-decoration: underline;
应用于<a>
标签,因此,如果您想跳过它,或者您希望网站上的所有<a>
标签都不要带有下划线,而不仅仅是使用下划线这个
Reason: text-decoration: underline;
is applied to <a>
tag by default browser stylesheet, so if you want to over ride it or if you want that none of the <a>
tags on your website should have an underline than simply use this
a {
text-decoration: none;
}
在我阅读您的评论时,如果您希望除<span>
内的文字之外的文字下划线,请使用
As I read your comment if you want your text to be underline except the text within <span>
than use this
ul li ul li a {
text-decoration:underline;
}
ul li ul li a span {
text-decoration:none;
display: inline-block;
}
这篇关于从锚内跨度上删除下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!