f-layout guide

f-layout is an easy to use alternative to grid layouts. A family of composable CSS classes designed to quickly enable responsive flexbox-based layout on IE 11+, Edge, Chrome, Firefox and Safari browsers.

Using CSS for laying out pages has always been tricky and before CSS3 was done mainly by misusing CSS features in order to get the job done. The idea behind f-layout is use modern CSS (now well supported in browsers) to create a small set of easily learned classes to enable web designers to build layouts quickly.

It uses the flexbox CSS model but tries to avoid complexity by surfacing only its most useful features and to have sensible defaults to make layout building as simple as possible.

In f-layout, all layout is either in a row or a column or a nested combination. Flow is from left to right, top to bottom. For element alignment, it follows CSS conventions of using terms like "left", "right", "top" and "bottom". It also uses the term "center" to denote horizontal centering as opposed to "middle" for vertical centering.

Elements can be hidden or shown and reordered. All of the features of f-layout can be applied responsively so as to deal with different device screen widths.

All classes can be suffixed with s, m or l and these suffixes correspond to screen width break points:

suffixmeaningbreak point
ssmallless than 600px
mmedium601px to 992px
llargemore than 992px

Row layout

Alignment defaults: f-space-between, f-middle

Left
1 2 3
Center
1 2 3
Right
1 2 3
Space between (default)
1 2 3
Space around
1 2 3
Top
1 2 3
Middle (default)
1 2 3
Bottom
1 2 3
Stretch (default)
1 2 3
Baseline
b i g

Column Layout

Alignment defaults: f-space-between, f-center

Top
1 2 3
Middle
1 2 3
Bottom
1 2 3
Space between (default)
1 2 3
Space around
1 2 3
Left
1 2 3
Center (default)
1 2 3
Right
1 2 3
Stretch
1 2 3

Self alignment

Finer-grained alignment of individual element be achieved with "self" alignment classes

Self Top
1 2 3
Self Middle
1 2 3
Self Bottom
1 2 3
Self Stretch
1 2 3
Self Baseline
b i g
Self Left
1 2 3
Self Center
1 2 3
Self Right
1 2 3
Self Stretch
1 2 3

Wrap Row

Normally all elements appear on one line but they can be made to wrap over multiple lines.
Wrap Top
1 2 3 4 5 6
Wrap Middle
1 2 3 4 5 6
Wrap Bottom
1 2 3 4 5 6
Wrap Space Around
1 2 3 4 5 6
Wrap Space Between
1 2 3 4 5 6

Wrap Column

Wrap Left
1 2 3 4 5 6
Wrap Center
1 2 3 4 5 6
Wrap Right
1 2 3 4 5 6
Wrap Space Around
1 2 3 4 5 6
Wrap Space Between
1 2 3 4 5 6

Grow

Growing elements take the available space
1 2 3
1 2 3
Two growing elements share the space
1 2 3
1 2 3
Using with text alignment
1 2 3
Ordering
1 2 3
Responsive layout
1 2 3

Toolbar example with grow

menu Welcome to f-layout email

Toolbar nested in a column with scrolling page that grows

menu Welcome to f-layout email

Above example nested in row layout with responsive side navigation

Logo
123
456
789
menu Welcome to f-layout email

Internet Explorer 11 Alignment

Alignment of items require that the element have a height or width specified or inherited. Simply specifying a max-height or max-width is not enough.

Additional classes used in these examples