Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用特征检测来确定浏览器是否支持 :hover 伪类?如果可能的话,我想不使用条件注释来包含特定于 ie6 的脚本文件。
:hover 伪类由符合标准的浏览器支持。像 IE6 这样的浏览器只支持<a>元素。
<a>
但是,您可以使用 jQuery 在任何事物上使用悬停更改,仅举一个例子。
$('.class').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); });
在你的 CSS 中,使用类 .hover 代替伪类 :hover
如果是 ie6 或更高版本,则不支持悬停。任何其他不支持悬停的浏览器都太旧且晦涩难懂。
编辑
可以:hover在 ie 6 中工作:请参阅此处
:hover