Html CSS - a:visited:hover?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1337033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:43:05  来源:igfitidea点击:

CSS - a:visited:hover?

htmlcssstylesheet

提问by

How can I apply a font coloronly to hyperlinks which have already been visitedand are being hoverby the mouse?

如何color仅将字体应用于鼠标已经visited和正在被hover鼠标操作的超链接?

Essentially, what I want to do is

本质上,我想做的是

a:visited:hover {color: red}

采纳答案by Gumbo

Yes that is possible.

是的,这是可能的。

Here's an example:

下面是一个例子:

<style type="text/css">
    a:link:hover {background-color:red}
    a:visited:hover {background-color:blue}
</style>

<a href="http://www.google.com/">foo</a><a href="http://invalid/">bar</a>

回答by user3110896

there is a sequence between link css to take effect.. a:hover must come after a:link and a:visited and a:active must come after a:hover for more details refer below link..

链接 css 之间有一个序列才能生效.. a:hover 必须在 a:link 和 a:visited 之后,a:active 必须在 a:hover 之后,有关更多详细信息,请参阅以下链接..

http://www.w3schools.com/css/css_pseudo_classes.asp

http://www.w3schools.com/css/css_pseudo_classes.asp

回答by Harry The Mad Lurker

There is a css declaration order for this to work properly as was mentioned earlier, although it didn't cover this particular option, it does make a difference. I've tested this on Chrome.

如前所述,有一个 css 声明顺序可以使其正常工作,尽管它没有涵盖这个特定选项,但它确实有所作为。我已经在 Chrome 上测试过了。

The order is

订单是

    a:link { color: red; }
    a:visited { color: blue; }
    a:visited:hover { color: yellow; }
    a:hover { color: green; }
    a:active { color: gray; }

It will work whether it comes before or after a:hover as long as both a:hover and a:visited:hover are after a:visited and before a:active. I just prefer to keep the two visited links together and the two hovers together.

只要 a:hover 和 a:visited:hover 都在 a:visited 之后和 a:active 之前,无论它出现在 a:hover 之前还是之后,它都会起作用。我只是更喜欢将两个访问过的链接保持在一起,并且两个悬停在一起。

回答by Brandon Hill

FWIW, I was unable to style just coloron a:visited:hover(Chrome/FF) without declaring a background for :link:hover(anything other than noneor inheritseems to work, I used rgba()for alpha sake).

FWIW,我无法colora:visited:hover不声明背景的情况下仅在(Chrome/FF)上设置样式(:link:hover除了noneinherit似乎有效,我用于rgba()alpha 的目的)。

For this to work in Chrome/FF:

要使其在 Chrome/FF 中工作:

a:visited:hover {
    color: #f00;
}

... (something like) this must be present:

...(类似)这必须存在:

a:link:hover {
    background-color: rgba(255, 255, 255, 0);
}