Hacker News new | past | comments | ask | show | jobs | submit login

can anyone think of a situation where flexbox > css grid? (apart from compatibility). On a similar note, is there any use case where float is still best?



Float might still be the best option for its original design intent: word processor style documents where images are placed within text flows. In other words, something like a blog post's content (but not the UI chrome).


Flexbox: distributing a variable number of elements, like an image gallery.

Float: in sections where there could be a variable number of columns, and the columns could have variable possible widths, using floats can be simpler than grids.

This is because you have to maintain many different grids (and their media queries) for the parent display:grid elements, and with floats you're only styling child elements.


I'm not sure I follow your second example. I might need more detail to understand how grid-auto-columns (https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-c...) does not meet this use case? It's possible I haven't been in the weeds enough on grid yet.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: