hover 被视为专注于移动浏览器
is hover treated as focused on mobile browsers
我注意到,有时如果某个元素在移动浏览器上为其 :hover
状态定义了 css 规则,只要元素具有焦点,就会应用这些规则。这是预期的行为吗?
根据 W3,当 "some pointing device" 放置在元素上时应用 :hover
:
The :hover pseudo-class applies while the user designates an element
(with some pointing device), but does not activate it. For example, a
visual user agent could apply this pseudo-class when the cursor (mouse
pointer) hovers over a box generated by the element. User agents not
supporting interactive media do not have to support this pseudo-class.
Some conforming user agents supporting interactive media may not be
able to support this pseudo-class (e.g., a pen device).
W3 src
所以,不,:hover
可能不支持,并且在某些移动设备上不支持。
您应该改用 :focus
。
Does css hover work on mobile devices?
我注意到,有时如果某个元素在移动浏览器上为其 :hover
状态定义了 css 规则,只要元素具有焦点,就会应用这些规则。这是预期的行为吗?
根据 W3,当 "some pointing device" 放置在元素上时应用 :hover
:
The :hover pseudo-class applies while the user designates an element (with some pointing device), but does not activate it. For example, a visual user agent could apply this pseudo-class when the cursor (mouse pointer) hovers over a box generated by the element. User agents not supporting interactive media do not have to support this pseudo-class. Some conforming user agents supporting interactive media may not be able to support this pseudo-class (e.g., a pen device).
W3 src
所以,不,:hover
可能不支持,并且在某些移动设备上不支持。
您应该改用 :focus
。
Does css hover work on mobile devices?