需要CSS文本颜色来使a:hover优先于a:visited [英] Need CSS text color for a:hover to take precedence over a:visited

查看:81
本文介绍了需要CSS文本颜色来使a:hover优先于a:visited的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些CSS代码,可将鼠标悬停时显示背景色.文本是蓝色背景上的白色.

I have some css code that shows a background color on hover. The text is white on a blue background.

否则,如果没有悬停,则文本为带有白色背景的蓝色. 但是,访问链接后,文本将保持蓝色,并且悬停时显示蓝色背景.

Otherwise, if there is no hover, the text is blue with a white background. However, when the link has been visited, the text remains blue with a blue background on hover.

如何强制悬停文本颜色优先?

How can I force the hover text color to take precedence?

a:link{
    color:#3399cc;
}

a:hover{
    background-color:#3399cc;
    color:#ffffff;
}
a:visited{
    color:#3399cc;
}
a:active{
    color:#3399cc;
}

推荐答案

我认为在:hover 之后指定样式数据:visited足以解决问题:

I think specifying the style data for :hover after the style data for :visited is enough to do the trick:

a:visited{  
    color:#3399cc;  
}  
a:hover{  
    background-color:#3399cc;  
    color:#ffffff;  
}

这篇关于需要CSS文本颜色来使a:hover优先于a:visited的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆