column-count
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since März 2017.
Die column-count CSS Eigenschaft teilt den Inhalt eines Elements in die angegebene Anzahl von Spalten auf.
Die columns Kurzform-Eigenschaft kann verwendet werden, um die Werte für column-count, column-height und column-width in einer einzigen Deklaration festzulegen.
Probieren Sie es aus
column-count: 2;
column-count: 3;
column-count: 4;
column-count: auto;
column-width: 8rem;
<section id="default-example">
<p id="example-element">
London. Michaelmas term lately over, and the Lord Chancellor sitting in
Lincoln's Inn Hall. Implacable November weather. As much mud in the streets
as if the waters had but newly retired from the face of the earth, and it
would not be wonderful to meet a Megalosaurus, forty feet long or so,
waddling like an elephantine lizard up Holborn Hill.
</p>
</section>
#example-element {
width: 100%;
text-align: left;
}
Syntax
/* Keyword value */
column-count: auto;
/* <integer> value */
column-count: 3;
/* Global values */
column-count: inherit;
column-count: initial;
column-count: revert;
column-count: revert-layer;
column-count: unset;
Werte
auto-
Die Anzahl der Spalten wird durch andere CSS-Eigenschaften, wie z.B.
column-width, bestimmt. <integer>-
Ist ein strikt positiver
<integer>und beschreibt die ideale Anzahl von Spalten, in die der Inhalt des Elements aufgeteilt werden soll. Wenn diecolumn-widthebenfalls auf einen Nicht-autoWert gesetzt ist, gibt sie lediglich die maximal zulässige Anzahl an Spalten an.
Formale Definition
| Anfangswert | auto |
|---|---|
| Anwendbar auf | Blockcontainer außer Tabellen umgebende Boxen |
| Vererbt | Nein |
| Berechneter Wert | wie angegeben |
| Animationstyp | Integer |
Formale Syntax
column-count =
auto |
<integer [1,∞]>
<integer> =
<number-token>
Beispiele
>Aufteilung eines Absatzes in drei Spalten
HTML
<p class="content-box">
This is a bunch of text split into three columns using the CSS
<code>column-count</code>
property. The text is equally distributed over the columns.
</p>
CSS
.content-box {
column-count: 3;
}
Ergebnis
Spezifikationen
| Specification |
|---|
| CSS Multi-column Layout Module Level 1> # cc> |
Browser-Kompatibilität
Siehe auch
column-heightcolumn-widthcolumnsKurzformcolumn-rule-color,column-rule-style,column-rule-width,column-ruleKurzform- Lernen: Mehrspalten-Layout (Lernen Layout)
- Grundlegende Konzepte von Multicol