Unlimited Grid Layout. Now with flexbox flavour — Updated
As promised I released the Flex Box Layout Module version of the Unlimited Grid Layout Boilerplate.
I would wanted to build a version compatible with old and actual Flexbox model's syntax but it was not possible to make a correct version with the syntax of 2009.
Anyway, I agree with Chris Coyier when he say: "Despite more support, it's not smart to be using the older syntax". So I decided to release only the new syntax version hoping that browser vendors realease soon a version which supporting the specification.
As in the, now named, inline-block version, look at the demos is the best way to learn about this technique. Warning: Chrome 21 or Opera 12.10 browsers required .
Unlimited Grid Layout Flexbox Demo — Ordered by Columns
Unlimited Grid Layout Flexbox Demo — Ordered by Rows
As you will see in the css, which is fully commented, this version in much more simpler than the inline-block one.
Only two properties are involved in this version and both are on the container responsible of stacking pages horizontally.
They are: display: flex; and flex-flow: row nowrap;.
The display: flex; property triggers the Flexbox layout on the container and the flex-flow: row nowrap; place the child elements in a row and prevents them to wrap around.
Without any other declaration the container's width will be divided equally by all the child elements, as defined in the Flexbox specifications. To override this behavior we have to add the declaration min-width: 100%; to every child element.
Update! To force the boxes to be as wide as the container we have to add the declaration flex: 0 0 100%; to every child element.
The flex declaration is a shorthand for flex-grow, flex-shrink and flex-basis properties.
Setting the flex shorthand to 0 0 100% we stop the flexbox to trying to redistribute free space across elements and force the initial width of every box as 100% of the parent's width.
Thats it! Really, really simple.
The drawback is the inexistent support by current browsers. At the time of writing only Chrome 21+ and Opera starting from v12.10 browsers support the properties needed to achieve the result.
Ok, now we can wait that browser vendors will support soon the new W3C Reccomendation but, meanwhile, if anyone would use this boilerplate in a production project I reccommend the inline-block version.
I hope you can find this boilerplate useful even if it cover just a really particular layout. If you have any suggestions or if you build an working old flexbox syntax version od this code, please, let me know.
Have fun and stay tuned.















