Html 从锚点内的跨度中删除下划线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13856330/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove underline from span inside anchor
提问by Hommer Smith
I have this HTML:
我有这个 HTML:
<ul>
<li>
<ul>
<li>
<a href="#"> <span> Test </span> Link </a>
</li>
</ul>
</li>
</ul>?
And this CSS:
这个CSS:
ul li ul li span {
text-decoration:none;
}?
Why would the span inside the anchor still have underline?
为什么anchor里面的span还有下划线?
In other words: How would I get all the text underlined, exceptthe SPAN. Thanks
换句话说:除了SPAN之外,我如何让所有文本都加下划线。谢谢
回答by Mr. Alien
You need to target the anchor tag
and not the span tag
so use this
你需要定位anchor tag
而不是span tag
所以使用这个
ul li ul li a {
text-decoration:none;
}?
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
原因:默认text-decoration: underline;
应用于<a>
浏览器样式表的标签,因此如果您想覆盖它,或者如果您希望<a>
您网站上的任何标签都不应该有下划线,而是简单地使用它
a {
text-decoration: none;
}
Edit: As I read your comment if you want your text to be underline except the text within <span>
than use this
编辑:当我阅读您的评论时,如果您希望您的文本带有下划线,除了里面的文本<span>
之外,请使用它
ul li ul li a {
text-decoration:underline;
}
ul li ul li a span {
text-decoration:none;
display: inline-block;
}
回答by Sowmya
回答by Animesh
回答by Ruchira Shree
It should be
它应该是
ul li ul li a {
text-decoration:none;
}?