A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Add :wrapped pseudo selector

mlavault
2016-08-23

It would be super useful to have a :wrapped CSS selector which could allow to apply CSS on elements that are in a flex container with flex-wrap:wrap when the flex container effectively wraps. For example to apply different margin/padding, change the text alignment, …

tabatkins
2016-08-23

In general, we can’t have CSS selectors that depend on CSS styles - in most cases it causes circular dependencies, and when it doesn’t, it would still require an expensive looping operation that we’re loathe to saddle pages with.

This goes a bit further; we definitely can’t have CSS selectors that depend on layout - circularity is virtually guaranteed (what you’re describing is definitely circular - you could use :wrapped to restyle the elements so the flexbox doesn’t wrap anymore), and the “loop” we’d have to perform before the page was done styling is much larger and much more expensive.

mkay581
2016-08-24

Can this currently be done in JS as an alternative? Then just add/remove a wrapped css class to the element? I don’t see any DOM event in the spec that triggers when an element begins to wrap.

mlavault
2016-08-24

Thanks for the detailed explanation, it makes sense.

mlavault
2016-08-24

Indeed a JS DOM event would help a lot :slight_smile: