CSS Columns for Bricks
A Bricks extension (no new element). Flow text, or a stack of children, across newspaper-style columns. Content runs down one column and continues at the top of the next, which flex and grid cannot do.
Version: 0.1.0 · Requires: Bricks · See the live demo
Installation
- Upload and activate the plugin. Bricks must be active.
- Select a Container, Block, Div, Text or Basic text element in Bricks. The CSS columns group is on the Style tab.
- Set Columns or Ideal column width.
Settings
- Columns (default: empty). The number of columns, 1 to 12. With an ideal width as well, this is the most columns allowed.
- Ideal column width (default: empty). As many columns as fit at this width. The browser drops to fewer columns on narrow screens by itself.
- Column gap (default:
1em) - Rule between columns (default: None). None, Solid, Dashed, Dotted or Double.
- Rule width and Rule colour. Shown once a rule style is chosen.
- Fill (default: Balance columns). Balance gives columns of similar length. Fill in order fills the first column to the element’s height before starting the next, so the element needs a height.
- Keep each child in one piece (default: Off). A child is never split across two columns.
- Space below each child (default:
0). Columns ignore flex and grid gaps, so spacing between stacked children is set here.
Every control is a native Bricks style control. It is responsive, so you can set a different number of columns for each breakpoint, and it shows live in the builder.
Quick start
- Add a Text element with several paragraphs.
- On its Style tab, open CSS columns and set Columns to 3.
- Switch to the tablet portrait breakpoint and set Columns to 2, then to mobile landscape and set it to 1.
Helper classes
Add these as classes on the direct children of the column element.
nl-cols-spanstretches the child across every column. Good for a headline or a pull quote.nl-cols-wholenever splits the child across two columns.nl-cols-breakstarts the child at the top of a new column.
A spanning child splits the content into two sets of columns, one above it and one below.
How it works
- Multi-column layout only works on a block container. A flex or grid element ignores column-count. So setting Columns or Ideal column width also sets the element to
display: block. - The extra helper stylesheet (a few lines, for the three classes) loads only on pages that use CSS columns.
- No JavaScript.
Tips
- For a stack of cards, switch on Keep each child in one piece and set a space below each child. You get a masonry-style layout with no JavaScript.
- Use Ideal column width for text. It adapts to the space without a column count for every breakpoint.
- Keep text columns between about 18 and 30rem wide so lines stay comfortable to read.
Troubleshooting
- The columns do not appear — the element may have a layout set elsewhere, such as a global class with
display: flexor grid. Remove it, or use a plain Block or Text element. - Fill in order does nothing — that mode needs a height on the element. Without one the columns balance.
- The spacing between children is gone — flex and grid gaps do not apply in columns. Use Space below each child.
- A helper class does nothing — it must be on a direct child of the column element.
Known limits
- Setting a column count or width replaces a flex or grid layout set on the same element.
- Column spanning works on direct children only.
- Sticky and absolutely positioned children behave as they do in any multi-column layout.