DEV Community

Discussion on: Explain container queries like I'm five

Collapse
 
facundocorradini profile image
Facundo Corradini • Edited

It's pretty much the same idea as media queries, only based on the container width instead of the viewport size.

The idea is to build responsive components that can be reused in different webs/apps that might serve them in a great variety of layouts.

There are some concerns like circular dependencies that are preventing CSS from building that kind of stuff, but the CSS working group is already proposing some solutions that we might enjoy in the future.

As for right now, for some simple things we can get away with using the flex-grow:9999 hack or some of grid's repeat(auto-fit, minmax()) magic. For more complex stuff, the best approach so far is using a little bit of JS with the Intersection Observer API, as Philip Walton's Responsive Components

Collapse
 
rnrnshn profile image
Olimpio

Ohhh. Seems amazing... Thanks...