Re: [csswg-drafts] [css-conditional] Applying styles based on an elements size (@media for elements) (#3852)

> if you (or anyone) have any suggestions on how we can both solve web developer's use cases while also avoiding layout thrashing and thus allowing it to be synchronous; I happily welcome them.

A large portion of use cases, for which web developers want container queries for, can be solved – I think – by CSS conditions that work with custom properties (aka CSS variables).

I proposed such a feature on [WICG Discourse two years ago](https://discourse.wicg.io/t/css-conditions-with-variables/2048) and wrote a short article about how I believe this can be a [solution to most container query use cases](https://au.si/css-conditions-cq-alternative). It doesn’t require layout thrashing and cannot result in endless loops.

This year I discovered that [CSS animations can be (mis)used to build something very similar](https://au.si/css-conditions-today). It is far away from being useful in production, but it shows that browsers and their CSS engines are capable of handling such a feature (in contrast to container queries). A short demo of this technique is [available on CodePen](https://codepen.io/ausi/pen/rPBNwJ/left/?editors=0100) and shows that CSS conditions are perfectly suitable for the main use case described in <https://wicg.github.io/cq-usecases/>

-- 
GitHub Notification of comment by ausi
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3852#issuecomment-494071606 using your GitHub account

Received on Monday, 20 May 2019 17:05:10 UTC