问题描述
看来,在一个时间点,组合多个伪选择器是可能的。例如,可以这样做: a:visited:hover {color:red}
Google快速搜索会显示多个此类实例,, 和。我无法在最新版本的Safari,Firefox或Chrome中使用此功能。
:visited
简短版本是,如果您可以以不同的方式设置:visited
链接,您可以使用它来确定访问了各种网站,因此根据他们的浏览器历史记录来定位他们。因此,大多数现代浏览器会严格限制可以对其进行的样式。
您仍然可以链接伪选择器。例如, a:focus:hover
只有在元素聚焦和悬浮时才能应用样式。请参见进行演示。
It appears that at one point in time combining multiple pseudo-selectors was possible. For example, one could do this:
a:visited:hover {color: red}
A quick Google search reveals multiple examples of this in action, here, here, and here. I am unable to get this feature to work in the latest versions of Safari, Firefox, or Chrome. Can anyone explain why this feature has regressed and/or been handicapped?
The :visited
pseudoclass can't be used for most styling in a lot of modern browsers anymore because it's a security hole. See this link for a more formal discussion on it.
The short version is that if you can style :visited
links differently, you can use that to determine if people have visited various sites, and therefore target them based on their browser history. Most modern browsers therefore heavily restrict the styling that can be done on them.
You can still chain pseudoselectors. For example, a:focus:hover
works just fine to apply styles only if the element is focused AND hovered. See this link for a demonstration.
这篇关于组合多个伪选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!