I have a case where I need to exclude media queries unless they match a specific element or elements.
Is there any way to specify data in the media query that will be ignored by query but retrievable?
var rules = document.styleSheets[0]["cssRules"] || document.styleSheets[0]["rules"];
var numberOfRules = rules!=null ? rules.length : 0;
// loop through rules and hide media queries except selected
for (var i=0;i<numberOfRules;i++) {
var rule = rules[i];
if (rule.media!=null) {
console.log(rule.conditionText);
}
}
@media (min-width: 500px) {
.hideOnMobile {
display: none !important;
}
}
I'd like to do something like:
@media (min-width: 500px) or (device: myElementName) {
.hideOnMobile {
display: none !important;
}
}
I've looked at the properties page but it doesn't look like anythings available.
https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries