CSS

列 | columns

columns

columns CSS属性是一个速记属性,允许同时设置column-widthcolumn-count同时性。

/* Column width */ columns: 1em; /* Column count */ columns: auto; columns: 1; /* Combination of column width and count */ columns: 1 auto; columns: auto 12em; columns: auto auto; /* Global values */ columns: inherit; columns: initial; columns: unset;

初始值作为简写的每个属性:column-width:auto column-count:auto
适用于除表格外包装盒的块容器
遗传没有
媒体 visual
计算值作为简写的每个属性:column-width:绝对长度,零或更大的列数:如指定的那样
动画类型作为简写的每个属性:column-width:长度column-count:整数
规范的顺序逐个语法

  • column-width*auto

  • column-count*auto

Applies to Block containers except table wrapper boxes [Inherited](inheritance) no Media visual [Computed value](computed_value) as each of the properties of the shorthand:

  • column-width*绝对长度,零或更大

  • column-count*具体规定

Animation type as each of the properties of the shorthand:

  • column-width*a长度

  • column-count*整型

Canonical order per grammar

语法

<'column-width'>是<length>给出列的最佳宽度的提示的值。实际的列宽可能会更宽(填充可用空间),或者更窄(仅当可用空间小于指定的列宽时)。长度必须严格肯定,否则声明无效。<'column-count'>严格正面<integer>描述元素内容将流入的理想列数。如果该column-width值也设置为非自动值,则仅表示允许的最大列数。

形式语法

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

HTML

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

CSS

.content-box { margin: 0; height: 90px; border: 3px solid black; columns: 3; }

结果

规范

SpecificationStatusComment
CSS Multi-column Layout ModuleThe definition of 'columns' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support(Yes) -webkit 50.01(Yes)-webkit (Yes)9 (9) -moz 52 (52)21011.10 15 -webkit3.0 (522)-webkit
on display: table-caption(Yes)(Yes)37 (37)(Yes)(Yes)(Yes)

FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support2.1 -webkit50.0(Yes)-webkit (Yes)22.0 (22) -moz 52.0 (52)21011.5 32 -webkit3.2 -webkit50.0
on display: table-caption(Yes)?(Yes)37.0 (37)(Yes)(Yes)(Yes)?