如何在HTML中使用HTML转换颜色并使用CSS删除下划线?

3 html css

如何在HTML中使用HTML转换颜色并使用CSS删除下划线?

str*_*ger 18

您想要查看:hover伪选择器,颜色属性文本修饰属性.

a:hover { color: red; text-decoration: none; }
Run Code Online (Sandbox Code Playgroud)

要确保您的超链接按照您的方式设置样式(并且不与其他样式规则冲突),请使用!important:

a:hover { color: red !important; text-decoration: none !important; }
Run Code Online (Sandbox Code Playgroud)


Pim*_*ger 7

除了stragers回答之外,请确保以LoVe HAte方式声明伪类.您必须声明:首先链接,然后:访问,然后:悬停然后:活动.否则某些浏览器可能不会应用伪类.

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)*/
}