I think to do this with flex, you will need to use the order property to make every 3rd element starting with 1 be first in order, which will give you the big squares all in the first column, with the smaller squares following in the second column.
I would have a go at throwing a Pen together, but I’m out of time tonight.
That’s nice work by Sam, but just be aware that this is a perfect scenario for display: grid. One of the tricks with using flexbox is knowing when it’s not the best tool.
Agreed!
I’ve already created this as a CSS Grid, but I’m hopeful to use Sam’s flexbox code as the start of a fallback for current IE, Edge and Safari browsers. Looks like CSS Grid is supported by Safari, but on my Windows 10 machine it breaks in Safari…
And so it should! Safari hasn’t been updated for Windows in many years, and is not a player in the Windows browser market any more.
Grid was released this year for most browsers, so it has pretty good support, but not universal. I think flexbox is a little better supported at this stage. The nice thing about both, though, is that you can arrange simple fallbacks for the browsers without support yet — which would satisfy everyone (web dev and clients) if this were a sane world.