删除链接中的蓝色下划线
我试图让链接显示为白色,没有下划线。文本颜色正确显示为白色,但蓝色下划线顽固地存在。我尝试在 CSS 中使用 text-decoration: none;
和 text-decoration: none !important;
来删除链接下划线。两者都不起作用。
.boxhead .otherPage {
color: #FFFFFF;
text-decoration: none;
}
<div class="boxhead">
<h2>
<span class="thisPage">Current Page</span>
<a href="myLink"><span class="otherPage">Different Page</span></a>
</h2>
</div>
如何删除链接中的蓝色下划线?
I am attempting to have a link show up in white, without an underline. The text color shows up correctly as white, but the blue underline is stubbornly persisting. I tried text-decoration: none;
and text-decoration: none !important;
in the CSS to remove the link underline. Neither worked.
.boxhead .otherPage {
color: #FFFFFF;
text-decoration: none;
}
<div class="boxhead">
<h2>
<span class="thisPage">Current Page</span>
<a href="myLink"><span class="otherPage">Different Page</span></a>
</h2>
</div>
How can I remove the blue underline from the link?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
您没有将
text-decoration: none;
应用于锚点 (.boxhead a
),而是应用于 span 元素 (.boxhead
)。试试这个:
You are not applying
text-decoration: none;
to an anchor (.boxhead a
) but to a span element (.boxhead
).Try this:
锚标记(链接)还具有诸如visited、hover、link和active等伪类。确保您的样式适用于相关状态,并且没有其他样式冲突。
例如:
有关 的更多信息,请参阅 W3.org用户操作伪类:hover、:active 和:focus。
The anchor tag (link) also has pseudo-classes such as visited, hover, link and active. Make sure your style is applied to the state(s) in question and that no other styles are conflicting.
For example:
See W3.org for more information on user action pseudo-classes :hover, :active, and :focus.
text-decoration: none !important
应该将其删除..您确定没有border-bottom: 1pxsolid
潜伏在其中吗? (在IE中跟踪Firebug/F12中的计算样式)text-decoration: none !important
should remove it .. Are you sure there isn't aborder-bottom: 1px solid
lurking about? (Trace the computed style in Firebug/F12 in IE)只需将此属性添加到您的锚标记
style="text-decoration:none;"
示例:
或者使用 CSS 方式。
Just add this attribute to your anchor tag
style="text-decoration:none;"
Example:
Or use the CSS way.
有时您会看到方框阴影,而不是文本下划线。
试试这个(使用任何适合你的 CSS 选择器):
Sometimes you're seeing a box shadow, not a text underline.
Try this (using whatever CSS selectors are appropriate for you):
您错过了锚标记的
text-decoration:none
。所以代码应该如下。文本装饰的更多标准属性
You missed
text-decoration:none
for the anchor tag. So the code should be the following.More standard properties for text-decoration
通常,如果您的“下划线”与文本的颜色不同(并且“颜色:”未被内联覆盖),则它不是来自“文本装饰:”。它必须是“边框底部:”。
不要忘记也去掉伪类的边框!
该片段假设它位于锚点上。相应地更改其包装器...并在找到根本原因后使用特异性而不是“!重要”。
As a rule, if your "underline" is not the same color as your text (and the 'color:' is not overridden inline), it is not coming from "text-decoration:". It has to be "border-bottom:".
Don't forget to take the border off your pseudo classes too!
This snippet assumes it's on an anchor. Change to its wrapper accordingly... And use specificity instead of "!important" after you track down the root cause.
在没有看到页面的情况下,很难推测。
但在我看来,您可能应用了
border-bottom: 1px Solid blue;
。也许添加border: none;
。text-decoration: none !important
是对的;不过,您可能有另一种样式仍然覆盖该 CSS。这就是使用 Firefox Web 开发者工具栏 的绝佳之处。您可以在那里编辑 CSS 并查看是否有效,至少对于 Firefox 而言是这样。它位于 CSS → 编辑 CSS 下。
Without seeing the page, it is hard to speculate.
But it sounds to me like you may have a
border-bottom: 1px solid blue;
being applied. Perhaps addborder: none;
.text-decoration: none !important
is right; it's possible that you have another style that is still overriding that CSS though.This is where using the Firefox Web Developer Toolbar is awesome. You can edit the CSS right there and see if things work, at least for Firefox. It's under CSS → Edit CSS.
虽然其他答案是正确的,但有一个简单的方法可以消除所有这些讨厌的链接上的下划线:
这将从页面上的每个链接中删除下划线!
While the other answers are correct, there is an easy way to get rid of the underline on all those pesky links:
This will remove the underline from every single link on your page!
没有一个答案对我有用。 有一个标准
就我而言,我的代码中 。基本上,无论它是什么链接,文本颜色都会变成蓝色,并且链接保持不变。
所以我在标题末尾添加了这样的代码:
问题不再存在。
None of the answers worked for me. In my case there was a standard
in my code. Basically whatever link it is, the text color goes blue, and the link stays whatever it is.
So I added the code at the end of the header like this:
And the problem is no more.
2023 更新
这个问题已经有点老了。一段时间以来,您可以在 CSS 中使用
all: unset
删除标签的所有功能。Update 2023
The question is already a bit older. Since a while you can delete all features of a tag with
all: unset
in CSS.您在错误的选择器中使用了text-decoration: none。您需要检查您需要哪个标签来装饰无。
您可以使用此代码
或
或
You've used text-decoration: none in the wrong selector. You need to check which tag do you need for decoration none.
You may use this code
Or
Or
正如其他人指出的那样,您似乎无法覆盖嵌套的文本装饰样式...但是您可以更改文本装饰颜色。
作为一种破解,我将颜色更改为透明:
As others pointed out, it seems like you can't override nested text-decoration styles... But you can change the text-decoration-color.
As a hack, I changed the color to be transparent:
在我的重置中,CSS 通常是:
In my reset, the CSS usually is:
只需使用该房产
即可享受保障。当 text-decoration 属性根本不起作用时,它对我来说非常有效。
Just use the property
and you are covered. It worked perfectly for me when the text-decoration property didn’t work at all.
如果
text-decoration: none
或border: 0
不起作用,请尝试在 HTML 内容中应用内联样式。If
text-decoration: none
orborder: 0
doesn't work, try applying inline style in your HTML content.将以下 HTML 代码放在
标签:
Put the following HTML code before the
<BODY>
tag:<STYLE>A {text-decoration: none;} </STYLE>
就我而言,我的 HTML 格式很差。该链接位于
标记内,而不是
标记内。
In my case, I had poorly formed HTML. The link was within a
<u>
tag, and not a<ul>
tag.设置
text-decoration: none;
作为锚标记。HTML 示例。
CSS 示例:
Set
text-decoration: none;
for the anchor tag.Example HTML.
Example CSS:
覆盖嵌套文本装饰样式。
查找任何 ::before 或 ::after 选择器,并对任何文本装饰、边框底部等不显示任何内容,或将属性(未设置)重置为任何文本颜色属性,例如: 文本装饰颜色、背景颜色等
或
Overriding nested text-decoration styles.
Look for any ::before or ::after selectors and display none to any text-decoration, border-bottom, etc. or reset a property (unset) to any text color property like: text-decoration-color, background-color, etc.
or
以下是 ASP.NET Web 表单 LinkButton 控件:
代码隐藏:
Here is an example for the ASP.NET Web Forms LinkButton control:
Code-behind: