5 ms·
Flexbox is conceptually more difficult than older float & grid based layout systems (it takes some time to wrap your head around the relationship between `displ
by pault 10y ago
Flexbox is conceptually more difficult than older float & grid based layout systems (it takes some time to wrap your head around the relationship between `display: flex` containers and the various flex-* properties that child elements utilize), but it makes certain things dead simple that were nearly impossible before. For example, vertically centering content (almost comically difficult before flexbox) and fixed-width elements mixed with expanding elements that will share unused space in a row. In a lot of ways flexbox acts like old-school table layouts--which were easy to use and predictable--but without the ugly, non-semantic, and verbose markup. Best of both worlds really.
They are supported in all self-updating browsers, so unless you have to support IE<=10 they are safe to use and extremely convenient. Replacing a classic grid-based layout with flexbox saves an astonishing amount of markup. I've been using it exclusively for the last six months or so.
I found this CSSTricks article helpful when I was building my first flexbox layouts: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ https://css-tricks.com/snippets/css/a-guide-to-flexbox/
- Drdrdrq 10y ago+1 for linking to Complete Guide to Flexbox. This guide is really great!
- wapz 10y agoThanks for the info. I did some simple CSS/HTML work a long time ago and never heard of flexbox (and it's everywhere on this page)
- zem 10y agoooh, mixing fixed-width with expanding elements is exactly the thing i'm struggling with now. i'll look into converting from grid to flex based layout and see how that goes.
- pault 10y agoYou can also use calc(100% - [fixed container width]px) in a pinch.
- archildress 10y agoThanks so much, this makes sense!