删除超链接 div 内链接的下划线
我正在使用下面的html,
<a href=""><div class="logo"><span class="whologo">hyperlinked text </span>
</div></a>
我遇到的问题是从跨度文本中删除下划线的唯一方法是使用 a:link{text-decoration:none;}
但这会从所有链接中删除下划线从整个页面
我已经尝试过
a.logo:link{text-decoration:none;}
,但它没有从 span 元素中删除超链接。
I am using the html below
<a href=""><div class="logo"><span class="whologo">hyperlinked text </span>
</div></a>
the problem i am having is that the only way to remove underline from the span text is using a:link{text-decoration:none;}
but this removes underlines from ALL links from the whole page
I have tried
a.logo:link{text-decoration:none;}
but it doesnt remove the hyperlink from the span element.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
你那里有一个错误的层次结构和错误的元素选择。对于你的情况,最准确的 CSS 是:
But I suggest this approach:
和CSS:
或者如果需要的话包含span(但前提是span元素有下划线,就像Hans在评论中指出的那样):
You have a wrong hierarchy there and bad element selection. In your case, the most accurate CSS would be:
But I suggest this approach:
And CSS:
Or include the span if needed (but only if the span element has underlines, like Hans pointed out in the comment):
子项无法使用 CSS 影响其父项。您需要将 ID 或类名称放在
A
标记上,或者在树上找到可以为此元素指定的唯一内容。Child items cannot influence their parents using CSS. You need to put an ID or class name on your
A
tag, or find something unique up the tree that you can specify for this element.看看这个
Check this out
在你不想要下划线的标签上放置一个类
,如下所示: http://jsfiddle.net/UL8SW/
Put a class on your a tag where you don't want the underline
like this : http://jsfiddle.net/UL8SW/
首先:这不是有效的 html...并且您应该为您的
a
提供一个类或 id,否则远程 css 无法实现这一点。内联CSS是可能的...First of all: This is not valid html... And you should give your
a
a class or id, otherwise this isnt possible with remote css. It is possible with inline css...给锚标记一个类。
HTML:
CSS:
Give anchor tag a class.
HTML:
CSS: