Similar to how numerous columns of text are defined in newspapers, the CSS multi-column layout makes this possible:
In this chapter you will learn about the following multi-column properties:
The numbers in the table specify the first browser version that fully supports the property.
The amount of columns into which an element should be divided is specified by the column-count property.
The text within the <div> element will be split into three columns in the example that follows:
div {
column-count: 3;
}
The space between the columns is specified by the column-gap property.
The sample that follows indicates a 40-pixel spacing between the columns:
div {
column-gap: 40px;
}
The style of the rule between columns is specified by the column-rule-style property:
div {
column-rule-style: solid;
}
The width of the rule between columns is specified by the column-rule-width property:
div {
column-rule-width: 1px;
}
The color of the rule in between columns is specified by the column-rule-color property:
div {
column-rule-color: lightblue;
}
Setting each of the aforementioned column-rule-* properties may be done quickly and easily with the column-rule property.
The width, style, and color of the rule between columns are set in the following example:
div {
column-rule: 1px solid lightblue;
}
The number of columns that an element should stretch across is specified by the column-span property.
The example that follows indicates that the <h2> element must extend to all columns:
h2 {
column-span: all;
}
The recommended, ideal width for the columns is specified by the column-width parameter.
The recommended, ideal width for the columns, as demonstrated in the example below, is 100 pixels:
div {
column-width: 100px;
}
The following table lists all the multi-columns properties:
Property | Description |
---|---|
column-count | Specifies the number of columns an element should be divided into |
column-fill | Specifies how to fill columns |
column-gap | Specifies the gap between the columns |
column-rule | A shorthand property for setting all the column-rule-* properties |
column-rule-color | Specifies the color of the rule between columns |
column-rule-style | Specifies the style of the rule between columns |
column-rule-width | Specifies the width of the rule between columns |
column-span | Specifies how many columns an element should span across |
column-width | Specifies a suggested, optimal width for the columns |
columns | A shorthand property for setting column-width and column-count |
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.