[英]How can I make a link in HTML turn a color when hovering and remove the underline using CSS?
如何在HTML中使用HTML转换颜色并使用CSS删除下划线?
You want to look at the :hover pseudoselector , the color property , and the text-decoration property. 您想要查看:hover伪选择器 , 颜色属性和文本修饰属性。
a:hover { color: red; text-decoration: none; }
To assure your hyperlink is styled as you want (and does not conflict with other style rules), use !important
: 要确保您的超链接按照您的方式设置样式(并且不与其他样式规则冲突),请使用
!important
:
a:hover { color: red !important; text-decoration: none !important; }
Also in addition to stragers answer, make sure to declare the pseudo classes in the LoVe HAte way. 除了stragers回答之外,请确保以LoVe HAte方式声明伪类。 You have to declare :link first, then :visited, then :hover and then :active.
您必须声明:首先链接,然后:访问,然后:悬停然后:活动。 Otherwise some browsers may not apply the pseudo classes.
否则某些浏览器可能不会应用伪类。
a:link{ /*this only apllies to named anchors*/ } a:visited{ /*possible styles for visited links*/ } a:hover{ /*when mouse hovers over a-tag*/ text-decoration:none; color:red; } a:active{ /*possible styles on active (when a-tag is clicked)*/ }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.