Is there a way to detect when an element wraps using only CSS (flexbox or grid)?

This article https://ishadeed.com/article/flex-wrap-detect/ probably answers my question, but I was wondering if maybe some new feature came up in CSS for this or maybe the article missed something?
Do we need CSS flex-wrap detection?
A look at why we need flex wrapping detection in CSS.
8 Replies
MarkBoots
MarkBoots2mo ago
i don't think it is really possible. but before we dive into it more.... What do you want to do with it if we can detect it? Maybe there are other options
relja
relja2mo ago
Well i want to change justify-content from space-evenly to space-between when this element goes down
No description
relja
relja2mo ago
When it goes down like this i want it to space-between
No description
relja
relja2mo ago
I need it to be dynamic because there can be more then 2 items in the div @MarkBoots any ideas? 🙂
MarkBoots
MarkBoots2mo ago
no, can't think of any without js. I was trying some container size queries, but they need defined sizes to work
relja
relja2mo ago
yea, thank you for taking some time out of your day to try it 😊
Hashi
Hashi2mo ago
Could it maybe work with container query that is based on the height, if it’s bigger than x then most likely it’s more than one “line”?
MarkBoots
MarkBoots2mo ago
for that the container needs to have an initial intrinsic height. it could work, but it's a bit magic numbery (and not sure it will cause issues in certain scenarios)
Want results from more Discord servers?
Add your server