Farhan Bashir’s Post

CSS :has() just flipped the script on how we style components. - Remember reaching for JavaScript just to style a parent based on its child's existence? - Or having to add extra classes for specific content scenarios? - Now, dynamic UI adjustments can live purely in your stylesheets. What are your most creative use cases for :has() so far? #FrontendDevelopment #CSS #WebDesign #WebDevelopment

  • No alternative text description for this image

Grid auto adjustment based on content is great use case .grid:has(.card:nth-child(3)) { grid-template-columns: repeat(3, 1fr); } layout adapts depending on number of children.

Like
Reply

Re: "What are your most creative use cases for :has() so far?" Giving a single parent element (with children) as many ::after pseudo-elements via: parent:has(child:hover)::after as it has children to :hover over.

See more comments

To view or add a comment, sign in

Explore content categories