any-hover

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2018.

any-hover CSS 媒体特性 可以用来测试是否有任意可用的输入机制可以在元素上 hover。

语法

any-hover 使用下面列表的值作为关键字。

none

可用的输入机制里没有机制可以方便地 hover,或者不存在定点输入机制。

hover

一个或多个可用的输入机制可以方便地在元素上 hover。

示例

测试是否有输入机制可以 hover

HTML

html
<a href="#">Try hovering over me!</a>

CSS

css
@media (any-hover: hover) {
  a:hover {
    background: yellow;
  }
}

结果

规范

Specification
Media Queries Level 4
# any-input

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
any-hover media feature

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

更多资料