简体   繁体   English

如何从链接中删除下划线并在 hover 上添加下划线? (附图片)

[英]How to remove underline from a link and add underline on hover? (images attached)

I want underline to be removed from a link.我想从链接中删除下划线。 Also I want underline to appear when I hover it with my mouse pointer.另外,当我用鼠标指针 hover 时,我希望出现下划线。 How can this be done?如何才能做到这一点? Pls help.请帮忙。

No hover:否 hover:无悬停 - 正常链接

When I hover the Login link:当我 hover Login链接:当我悬停登录链接时

You need to turn off the CSS property text-decoration for the link and then use the :hover dynamic pseudo class to add the text-decoration back when hovering.您需要关闭链接的 CSS 属性text-decoration ,然后在悬停时使用:hover动态伪 class添加text-decoration

a {
    text-decoration:none;
}

a:hover {
   text-decoration:underline;
}

Demo演示

Also, you might also need to style the :visited:hover pseudo class so that the underline appears on links a user has already visited.此外,您可能还需要设置:visited:hover伪 class 的样式,以便下划线出现在用户已经访问过的链接上。 link order in css is a good answer because the order of the CSS rules matters. css 中的链接顺序是一个很好的答案,因为 CSS 规则的顺序很重要。

Assuming your login link has the id login ...假设您的登录链接具有 id login ...

#login {
   text-decoration: none;
}

#login:hover {
   text-decoration: underline;
}

In your style sheet, whatever the ID is.在您的样式表中,无论 ID 是什么。

#LoginButton a:active {text-decoration: none;}
#LoginButton a:hover {text-decoration: underline; color: white;}

Call a CSSClass within the login button and define the following lines in the style sheet,在登录按钮中调用 CSSClass 并在样式表中定义以下行,

   .ClassName a:link {text-decoration:none;}//removes underline


   .ClassName a:hover {text-decoration:underline;}// displays underline on mouse over

Hope this helps..希望这可以帮助..

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

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