yup, :has is a game changer, would not be able to do my structural css editor without it.
I wrote a pure-css way to annotate the margin shorthand from
margin: 1px 2px 3px 4px
->
margin: top: 1px right: 2px bottom: 3px left: 4px
The following selector traverses the AST & checks if the margin is of that form, with the use of a little ::before and content you can do some really wild things.
Is the same as figure figcaption unless you’re selecting for “browser supports :has”.
The selector reads as “a figcaption which is the descendent of a figure which has a figcaption as a descendent”. But figcaption that was the descendent of a figure which doesn’t have a figcaption as a descendent would be paradoxical.
Oh, I never considered using it with nth-of-type and such. That’s an interesting mix. :not only lets you put a simple selector inside, has letting you use those is kinda hardcore. And browser support finally coming, golly.
This is a fantastic tutorial. I have read lots about
:has, and have used it a bunch, too, but this article opened my eyes to its potential.yup,
:hasis a game changer, would not be able to do my structural css editor without it.I wrote a pure-css way to annotate the margin shorthand from
->
The following selector traverses the AST & checks if the margin is of that form, with the use of a little
::beforeandcontentyou can do some really wild things.Is the same as
figure figcaptionunless you’re selecting for “browser supports:has”.The selector reads as “a
figcaptionwhich is the descendent of afigurewhich has afigcaptionas a descendent”. Butfigcaptionthat was the descendent of afigurewhich doesn’t have afigcaptionas a descendent would be paradoxical.Oh, I never considered using it with nth-of-type and such. That’s an interesting mix.
:notonly lets you put a simple selector inside, has letting you use those is kinda hardcore. And browser support finally coming, golly.