postcss-require-hover

0.1.0 • Public • Published

PostCSS Require Hover

PostCSS plugin that wraps hover selectors in a media media that's only valid on devices that support true hover events. The goal of this plugin is to prevent mobile browsers (mostly iOS) from getting their hover states "stuck" since hover.

Original idea: https://www.quirksmode.org/blog/archives/2012/11/what_the_hells.html

More explicit support for this feature: https://drafts.csswg.org/mediaqueries/#hover

Tested:

  • IE11
  • Chrome
  • Safari
  • Firefox
  • iOS - Safari/Chrome
  • Android - Chrome

Example

.foo {
    bar:hover {
        display: block;
    }
}
.foo {
    @media not all and (hover: none), (-ms-high-contrast: none) {
        bar:hover {
            display: block;
        }
    }
}

Installation

npm install postcss-require-hover

Usage

postcss([require("postcss-require-hover")]);

See PostCSS docs for examples for your environment.

Package Sidebar

Install

npm i postcss-require-hover

Weekly Downloads

51

Version

0.1.0

License

MIT

Unpacked Size

4.21 kB

Total Files

6

Last publish

Collaborators

  • jackburns