简体   繁体   English

悬停时删除下划线链接

[英]Remove underline link on hover

I am trying to remove my underline on hover and everything, but it doesnt seem to be working. 我正在尝试删除有关悬停和所有内容的下划线,但似乎不起作用。

<a href="agent_user_add.php"><font face="verdana" class="pluslink" style="font-size:26px;">+</font></a>

Below is my styling 下面是我的造型

.pluslink a:link {text-decoration:none;} .pluslink a:visited {text-decoration:none;} .pluslink a:hover {text-decoration:none;} .pluslink a:active {text-decoration:none;}

How come its not working? 它怎么不起作用? Am i putting the class in the wrong place? 我把课程放在错误的地方了吗?

Here is a jsfiddle below! 这是下面的jsfiddle!

jSfiddle jSfiddle

.pluslink, .pluslink:visited,.pluslink:hover,.pluslink:active {
   text-decoration:none;
 }
<a href="agent_user_add.php" class="pluslink">+</a>

See http://jsfiddle.net/3pTTR/ 参见http://jsfiddle.net/3pTTR/

fiddle updated 小提琴更新

Your styles are missing their target, as there is no a inside an element called pluslink . 您的样式缺少目标,因为在内部没有a名为pluslink的元素。 If you want to target this a specifically, you'll have to give it a class or target it through its parent element(s). 如果你想针对这a特别,你必须给它一个类或通过其父元素(一个或多个)目标吧。

As an aside, <font> is from the 1990s and way out of date. 顺便说一句, <font>是1990年代的,已经过时了。 Instead, target the a and set the fonts via CSS. 相反,定位a并通过CSS设置字体。

Add: 加:

a.pluslink {
    text-decoration:none;
}

Fiddle 小提琴

Manish Jangir's answer will work, or if you prefer more specific styles, you can go with: Manish Jangir的答案将起作用,或者,如果您更喜欢特定的样式,可以选择:

a .pluslink {text-decoration:none;}
a .pluslink:visited {text-decoration:none;}
a .pluslink:hover {text-decoration:none;}
a .pluslink:active {text-decoration:none;}

The font tag by default inherits it's text-decoration property from it's parent. 默认情况下, font标签从其父级继承其text-decoration属性。 In this case, you have the font tag wrapped in an a tag, which is defaults to text-decoration: underline . 在这种情况下,您将font标签包裹在a tag中,默认为text-decoration: underline

The CSS that you have is applied to a tags that are decedents of elements with a class of pluslink . 你有CSS应用到a标签是与类pluslink元素的死者。 In your case, the pluslink class is applied to the font tag, which is the child of the a tag. 在您的情况下, pluslink类将应用于font标签,它是a标签的子元素 The opposite of the CSS you're going for. 您要使用的CSS相反。

The easiest solution would be for you to move your font tag outside of your a tag: 最简单的解决办法是让你移动你的font标记的外a标签:

jsFiddle jsFiddle

Alternatively, you could apply the pluslink class to your a tag, and edit your CSS code to include the font-size and font-family. 或者,你可以应用pluslink类的a标签,并编辑你的CSS代码,包括字体大小和字体家族。 The font tag has been deprecated for some time now. font标签已经过时了一段时间。 This also makes your code more manageable. 这也使您的代码更易于管理。

jsFiddle jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM