column-rule 简写 CSS property sets the width, style, and color of the line drawn between columns in a multi-column layout.

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.

It is a shorthand property that sets the individual column-rule-* properties in a single, convenient declaration: column-rule-width , column-rule-style ,和 column-rule-color .

注意: As with all shorthand properties, any individual value that is not specified is set to its corresponding initial value (possibly overriding values previously set using non-shorthand properties).

句法

column-rule: dotted;
column-rule: solid 8px;
column-rule: solid blue;
column-rule: thick inset blue;
/* Global values */
column-rule: inherit;
column-rule: initial;
column-rule: unset;
					

column-rule property is specified as one, two, or three of the values listed below, in any order.

<'column-rule-width'>
<length> or one of the three keywords, thin , medium ,或 thick 。见 border-width 了解细节。
<'column-rule-style'>
border-style for possible values and details.
<'column-rule-color'>
<color> 值。

形式定义

初始值 as each of the properties of the shorthand:
适用于 multicol elements
继承 no
计算值 as each of the properties of the shorthand:
动画类型 as each of the properties of the shorthand:

形式句法

<'column-rule-width'> || <'column-rule-style'> || <'column-rule-color'>
					

范例

Example 1

/* Same as "medium dotted currentcolor" */
p.foo { column-rule: dotted; }
/* Same as "medium solid blue" */
p.bar { column-rule: solid blue; }
/* Same as "8px solid currentcolor" */
p.baz { column-rule: solid 8px; }
p.abc { column-rule: thick inset blue; }
					

Example 2

HTML

<p class="content-box">
  This is a bunch of text split into three columns.
  Take note of how the `column-rule` property is used
  to adjust the style, width, and color of the rule
  that appears between the columns.
</p>
					

CSS

.content-box {
  padding: 0.3em;
  background: #ff7;
  column-count: 3;
  column-rule: inset 2px #33f;
}
					

结果

规范

规范 状态 注释
CSS Multi-column Layout Module
The definition of 'column-rule' 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-rule Chrome 完整支持 50 Edge 完整支持 12 Firefox 完整支持 52
完整支持 52
不支持 3.5 — 74 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -moz-
注意事项 Before Firefox 3, the default value for the normal keyword was 0 and not 1em .
IE 完整支持 10 Opera 完整支持 11.1 Safari 完整支持 9 WebView Android 完整支持 50 Chrome Android 完整支持 50 Firefox Android 完整支持 52
完整支持 52
完整支持 4 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 11.1 Safari iOS 完整支持 9 Samsung Internet Android 完整支持 5.0

图例

完整支持

完整支持

见实现注意事项。

见实现注意事项。

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

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

元数据

  • 最后修改: