CSS Has Pseudo
CSS Has Pseudo lets you style elements relative to other elements in CSS, following the Selectors Level 4 specification.
Usage
From the command line, transform CSS files that use :has
selectors:
Next, use your transformed CSS with this script:
That’s it. The script is 765 bytes and works in all browsers, including Internet Explorer 11. With a Mutation Observer polyfill, the script will work down to Internet Explorer 9.
How it works
The PostCSS plugin clones rules containing :has
, replacing them with an alternative [:has]
selector.
Next, the JavaScript library adds a [:has]
attribute to elements otherwise matching :has
natively.
Last updated