简体   繁体   English

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

[英]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.

相关问题 在 html 中访问链接后如何删除下划线和紫色文本颜色 - How can I remove underline and purple text color after the link is visited in html <a>悬停在标签</a>下划线时如何使其<a>颜色改变</a> - How to make a underline of a <a> tag change color when hovering over it 如何在HTML / CSS中使用空格来阻止阻碍下划线的文本? - How can I make text that impedes on it's underline 'block out' the underline with whitespace in HTML/CSS? 将鼠标悬停在列表上时如何更改HTML链接的颜色? - How to alter the color of an HTML link when hovering over a list? 如何使用 CSS 去除下划线? - How to remove underline using CSS? Ckeditor 4-如何更改包含下划线的链接的颜色? - Ckeditor 4 - how can I change the color of the link including underline? 当我将鼠标悬停在链接上时,如何使背景色覆盖其所在的整个框架? - How can I, when hovering over a link, have the background color span the whole of the frame it is in? 将鼠标悬停在IE中的图片上时,如何删除下划线? - How to remove underline when hovering over an image in IE? 在HTML / CSS中访问链接时,使图像变为灰度 - Make an image turn greyscale when the link is visited in HTML/CSS 如何从UILabel的html链接中删除下划线? - How to remove underline from html link in UILabel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM