CSS multi column text
May 23rd, 2010 by JorisO | Filed under CSS3, Front-end development.CSS 3 provides a new collection of column properties that allow you to easily distribute a HTML container’s textual content over multiple vertical columns. At the time of writing this property is supported by Mozilla and Webkit browsers, and -moz / -webkit vendor prefixes are still needed.
- ‘column-count’, to determine the number of columns into which the content of the element will flow.
- ‘column-width’, to describe the preferred width of each column.
- ‘column-gap’, to set the padding between columns.
- ‘column-rule’, to define a border between columns.
column-count and column-gap
The column-count property allows you to specify the number of columns you wish to divide your columns into. The column gap then let’s you specify the space between your columns.
Example:
-moz-column-count: 2; -moz-column-gap: 20px; -webkit-column-count: 2; -webkit-column-gap: 20px; column-count: 2; column-gap: 20px;
This CSS will create the following column lay-out:
The style sheet specifies the number of columns and lets the UA choose the dimensions.
the style sheet specifies a column width and lets the UA determine how many columns there is room for.
the style sheet specifies both the number of columns and their widths
In all three cases, the UA determines the height of the columns based on the content which needs to be fitted. Content should be balanced between columns to minimize the heights of columns.
To describe the number and widths of columns, and the gap between columns, three new CSS properties are proposed.
column-width
The column-width property allows you to specify how wide you’d like your columns to be.
And so this css
-moz-column-width: 200px; -webkit-column-width:200px; column-width: 200px;
Results in this column lay-out:
The style sheet specifies the number of columns and lets the UA choose the dimensions.
the style sheet specifies a column width and lets the UA determine how many columns there is room for.
the style sheet specifies both the number of columns and their widths
In all three cases, the UA determines the height of the columns based on the content which needs to be fitted. Content should be balanced between columns to minimize the heights of columns.
column-rule
The rule directive let’s you specify a border in-between columns.
-moz-column-rule: 1px dotted black; -webkit-column-rule:1px dotted black ; column-rule: 1px dotted black; -moz-column-width: 200px; -webkit-column-width:200px; column-width: 200px;
Other articles on CSS3 multi column lay-outs :
[...] post: CSS multi column text – WipWapWebdesign This entry was posted on Sunday, May 23rd, 2010 at 4:02 pm and is filed under Uncategorized. You [...]