column-fill CSS property controls how an element's contents are balanced when broken into columns.

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.

句法

/* Keyword values */
column-fill: auto;
column-fill: balance;
column-fill: balance-all;
/* Global values */
column-fill: inherit;
column-fill: initial;
column-fill: unset;
					

column-fill property is specified as one of the keyword values listed below. The initial value is balance so the content will be balanced across the columns.

auto

Columns are filled sequentially. Content takes up only the room it needs, possibly resulting in some columns remaining empty.

balance
Content is equally divided between columns. In fragmented contexts, such as paged media , only the last fragment is balanced. Therefore in paged media, only the last page would be balanced.
balance-all
Content is equally divided between columns. In fragmented contexts, such as paged media , all fragments are balanced.

形式定义

初始值 balance
适用于 multicol elements
继承 no
计算值 如指定
动画类型 discrete

形式句法

auto | balance | balance-all
					

范例

Balancing column content

HTML

<p class="fill-auto">
  This paragraph fills columns one at a time. Since all of the text can fit in the first column, the others are empty.
</p>
<p class="fill-balance">
  This paragraph attempts to balance the amount of content in each column.
</p>
					

CSS

p {
  height: 7em;
  background: #ff9;
  columns: 3;
  column-rule: 1px solid;
}
p.fill-auto {
  column-fill: auto;
}
p.fill-balance {
  column-fill: balance;
}
					

结果

规范

规范 状态 注释
CSS Multi-column Layout Module
The definition of 'column-fill' 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
column-fill Chrome 完整支持 50 Edge 完整支持 12 Firefox 完整支持 52
完整支持 52
不支持 13 — 74 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 完整支持 10 Opera 完整支持 37 Safari 完整支持 9 WebView Android 完整支持 50 Chrome Android 完整支持 50 Firefox Android 完整支持 52
完整支持 52
完整支持 14 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 37 Safari iOS 完整支持 9 Samsung Internet Android 完整支持 5.0
balance-all Experimental Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

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

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

Note that there are some interoperability issues and bugs with column-fill across browsers, due to unresolved issues in the specification.

In particular, when using column-fill: auto to fill columns sequentially, Chrome will only consult this property if the multicol container has a size in the block dimension (e.g., height in a horizontal writing mode). Firefox will always consult this property, therefore filling the first column with all of the content in cases where there is no size.

元数据

  • 最后修改: