The World's Smallest Container Query Plugin
Define a 'container' using a CSS selector, run a JavaScript test on matching HTML elements, and apply CSS styles to the container or its child elements if the test resolves true
.
q(containerList, condition, childList, rule)
containerList
is a comma-separated string containing one or more CSS selectorscondition
is a JavaScript test that should evaluate totrue
orfalse
childList
is a comma-separated string containing one or more CSS selectorsrule
is a semicolon-separated string containing one or more CSS declarations
q('div', 'this.offsetWidth > 500', 'span', 'background: lime')
This plugin lovingly golfed by: