Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
hover-media-query
Advanced tools
A progressively enhanced "hover" media query.
Detailed info about the Hover CSS media feature can be found on the MDN website.
This CSS media feature is implemented and supported in almost all modern browsers and works as expected.
The modern browsers include Chrome, Opera, Safari, Edge, Brave, Vivaldi, etc.
Internet Explorer and Firefox (prior v.64) do not understand this media feature and therefore will simply ignore all rules inside the query.
The Hover Media Query module provides means to progressively enhance the CSS hover state by providing a unified set of media queries which target all browsers:
those which support the hover media query and:
those which do not support the hover media query at all
The following example shows how to use the Hover Media Query and target all browsers which support the hover
CSS media query.
The following example targets also browsers which do not support it (such as IE and Firefox prior v.64).
/**
* Enable hover states on devices which support hover media feature.
* On IE10, IE11 and Firefox prior v.64 hover states work on any device.
*
* -ms-high-contrast: none Targets IE10 and IE11
* -ms-high-contrast: active Targets IE10 and IE11
* -moz-touch-enabled: 0 Targets Firefox before 64
* hover: hover Targets all browsers which support the Hover CSS Media Feature
*/
@media (-ms-high-contrast: none), (-ms-high-contrast: active), (-moz-touch-enabled: 0), (hover: hover) {
.element:hover {
color: lavender;
}
}
The following example shows how to use the Hover Media Query and target all browsers which support the hover
media query but do not support the CSS hover state (such as mobile browsers which are usually used without a pointer device).
/**
* For devices which support the "hover" media query but do not support ":hover" state
* the following media query disables the highlight color on tap on the element and
* adds styles to the ":active" state
*/
@media (hover: none) {
.element {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.element:active {
color: lavender;
}
}
If your environment supports the SCSS language, you can use the SCSS provided here:
First define the SCSS mixin:
@mixin hover {
@media (hover: none) {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
&:active {
@content;
}
}
@media (-ms-high-contrast: none), (-ms-high-contrast: active), (-moz-touch-enabled: 0), (hover: hover) {
&:hover {
@content;
}
}
}
Or import it:
@import 'hover-media-query/hover.scss';
And then use it wherever appropriate:
.button {
@include hover {
color: lavender;
}
}
If your environment is configured to use the PostCSS postprocessor, you can use the custom PostCSS media queries. In order to to so you need to install and configure the PostCSS Custom Media plugin
First define the custom media queries:
@custom-media --hover (-ms-high-contrast: none), (-ms-high-contrast: active), (-moz-touch-enabled: 0), (hover: hover);
@custom-media --no-hover (hover: none);
Or import them:
@import 'hover-media-query/hover.css';
And then use them wherever appropriate:
@media (--hover) {
.button:hover {
color: lavender;
}
}
@media (--no-hover) {
.button {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button:active {
color: rebeccapurple;
}
}
MIT
14 August 2023
#91
#88
#90
#89
#86
#84
#83
#82
#81
#80
#79
4a4c8d9
ec4043e
907a415
FAQs
A progressively enhanced "hover" media query.
The npm package hover-media-query receives a total of 95 weekly downloads. As such, hover-media-query popularity was classified as not popular.
We found that hover-media-query demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.