columns CSS shorthand property sets the number of columns to use when drawing an element's contents, as well as those columns' widths.

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

组成特性

此特性是下列 CSS 特性的简写:

句法

/* Column width */
columns: 18em;
/* Column count */
columns: auto;
columns: 2;
/* Both column width and count */
columns: 2 auto;
columns: auto 12em;
columns: auto auto;
/* Global values */
columns: inherit;
columns: initial;
columns: unset;
					

columns property may be specified as one or two of the values listed below, in any order.

<'column-width'>
The ideal column width, defined as a <length> or the keyword auto . The actual width may be wider or narrower to fit the available space. See column-width .
<'column-count'>
The ideal number of columns into which the element's content should be flowed, defined as an <integer> or the keyword auto . If neither this value nor the column's width are auto , it merely indicates the maximum allowable number of columns. See column-count .

形式定义

初始值 as each of the properties of the shorthand:
适用于 Block containers except table wrapper boxes
继承 no
计算值 as each of the properties of the shorthand:
动画类型 as each of the properties of the shorthand:

形式句法

<'column-width'> || <'column-count'>
					

范例

Setting three equal columns

HTML

<p class="content-box">
  This is a bunch of text split into three columns
  using the CSS `columns` property. The text
  is equally distributed over the columns.
</p>
					

CSS

.content-box {
  columns: 3 auto;
}
					

结果

规范

规范 状态 注释
CSS Multi-column Layout Module
The definition of 'columns' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
columns Chrome 完整支持 50 Edge 完整支持 12 Firefox 完整支持 52
完整支持 52
不支持 9 — 74 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -moz-
注意事项 Prior to version 37, multiple columns didn't work with display: table-caption elements.
IE 完整支持 10 Opera 完整支持 11.1 Safari 完整支持 9 WebView Android 完整支持 50 Chrome Android 完整支持 50 Firefox Android 完整支持 52
完整支持 52
完整支持 22 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -moz-
注意事项 Prior to version 37, multiple columns didn't work with display: table-caption elements.
Opera Android 完整支持 11.1 Safari iOS 完整支持 9 Samsung Internet Android 完整支持 5.0

图例

完整支持

完整支持

见实现注意事项。

见实现注意事项。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

元数据

  • 最后修改: