GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing developer.mozilla.org — columns CSS property - CSS | MDN
|
| Initial value | as each of the properties of the shorthand:
|
|---|---|
| Applies to | Block containers except table wrapper boxes |
| Inherited | no |
| Computed value | as each of the properties of the shorthand:
|
| Animation type | as each of the properties of the shorthand:
|
columns =
[ <'column-width'> || <'column-count'> ] [ / <'column-height'> ]?
<column-width> =
auto |
<box-size> |
auto |
<box-size>
<column-count> =
auto |
<integer [1,∞]>
<column-height> =
auto |
<length [0,∞]>
<box-size> =
<length-percentage [0,∞]> |
stretch |
contain |
min-content |
max-content |
fit-content |
stretch( <length-percentage [0,∞]> ) |
fit-content( <length-percentage [0,∞]> ) |
<calc-size()>
<integer> =
<number-token>
<length-percentage> =
<length> |
<percentage>
<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )
<calc-size-basis> =
<size-keyword> |
<calc-sum> |
<calc-size()> |
any
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
This example shows how to split a text container into three equal columns.
We include a basic <p> element containing text content.
<p class="content-box">
This is a bunch of text split into three columns using the CSS
<code>columns</code>
property. The text is equally distributed over the columns.
</p>
We set a columns property value on the paragraph that includes a <column-count> value of 3 and a <column-width> value of auto.
body {
width: 60%;
margin: 0 auto;
}
.content-box {
columns: 3 auto;
}
Note how the text is split up into three columns.
This example demonstrates including a <column-height> value with the columns shorthand property to split a text container into fixed-height columns that wrap onto new lines when the container inline edge is reached.
We include a basic <p> element with some text.
<p class="content-box">
This is a bunch of text split into three columns using the CSS
<code>columns</code> property. This includes a <code>column-count</code> value
of <code>3</code>, a <code>column-width</code> value of <code>auto</code>, and
a <code>column-height</code> value of <code>5em</code>. The
<code>column-wrap</code> value is set to its initial value, <code>auto</code>;
when a <code>column-height</code> value is included,
<code>column-wrap: auto</code> resolves to <code>wrap</code>, which allows the
columns to wrap onto multiple rows. The text is equally distributed over the
columns, and placed into multiple rows.
</p>
We set a columns property value on the paragraph that includes a <column-count> value of 3, a <column-width> value of auto, and a <column-height> value of 5em. Because the <column-height> is set to a <length>, the paragraph's column-wrap value computes to wrap, which allows the columns to wrap onto multiple rows.
.content-box {
columns: 3 auto / 5em;
}
body {
width: 60%;
margin: 0 auto;
}
@supports not (columns: 3 auto / 5em) {
body::before {
content: "Your browser does not support the 'column-height' property.";
background-color: wheat;
position: fixed;
inset: 40% 0;
height: fit-content;
text-align: center;
padding: 1rem 0;
}
}
Note how the text is split up into three columns. Each column is 5em high. After every third column, the columns wrap onto a new line in the block direction.
| Specification |
|---|
| CSS Multi-column Layout Module Level 2 # propdef-columns |