From the specifications:
none
Indicates that the main pointer system cannot be pointed, or there is no pointer system. Examples include touch screens and screens that use a stylus for drawing.
Indicative systems that may hang, but for which it is inconvenient, and are not part of the usual way of using them, also correspond to this value.
For example, a touch screen in which a long press is treated as a hang will correspond to a hang: none.
If your browser (mobile / touch) supports long presses to simulate hovering, using hover: none will not work. You can simply use the default value and override it (with default priority css):
body { background: red; } @media (hover: hover) { body { background: blue; } }
The desktop will have a blue background, and for mobile / touch there will be a red background
Check out the following example:
https://jsfiddle.net/mcy60pvt/1/
To test the possibility of a long press on a mobile phone, you can use this example:
https://jsfiddle.net/mcy60pvt/3/
In the above example, the green block has the definition :hover for the desktop and mobile device, however, for the desktop, the background will change to yellow , and for mobile devices (with a long press) it will change to white .
Here is the css example for the last example:
body { background: red; } div.do-hover { border: 1px solid black; width: 250px; height: 250px; background: green; } div.do-hover:hover { background: white; } @media (hover: hover) { body { background: blue; } div.do-hover:hover { background: yellow; } }
In this example, browsers that do not support :hover will view the hover me window with a green background, and during the "hover" (touch / long press), the background will change to white.
Update
Regarding the added pseudocode:
.myelement { } @media(hover: hover) { .myelement { } .myelement:hover { } }
Dekel Nov 10 '16 at 16:49 2016-11-10 16:49
source share