column-rule

Baseline 已广泛支持

此特性已得到良好确立,可跨多种设备和浏览器版本使用。自 2017 年 3 月起,所有浏览器均支持此特性。

column-rule 简写 CSS 属性用于设置多列布局中列之间绘制的线条的宽度、样式和颜色。

试一试

column-rule: dotted;
column-rule: solid 6px;
column-rule: solid blue;
column-rule: thick inset blue;
<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 {
  columns: 3;
  column-rule: solid;
  text-align: left;
}

构成属性

此属性是以下 CSS 属性的简写:

语法

css
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: revert;
column-rule: revert-layer;
column-rule: unset;

column-rule 属性可按任何顺序指定为以下所列值中的一个、两个或三个。

<'column-rule-width'>

是一个 <length> 值,或者是三个关键字之一:thinmediumthick。详见 border-width

<'column-rule-style'>

可能的取值和详情请参阅 border-style

<'column-rule-color'>

是一个 <color> 值。

正式定义

初始值作为简写中的每个属性
应用于多列元素
继承性
计算值作为简写中的每个属性
动画类型作为简写中的每个属性

正式语法

column-rule = 
<gap-rule-list> |
<gap-auto-rule-list>

<gap-rule-list> =
<gap-rule-or-repeat>#

<gap-auto-rule-list> =
<gap-rule-or-repeat>#? , <gap-auto-repeat-rule> , <gap-rule-or-repeat>#?

<gap-rule-or-repeat> =
<gap-rule> |
<gap-repeat-rule>

<gap-auto-repeat-rule> =
repeat( auto , <gap-rule># )

<gap-rule> =
<line-width> ||
<line-style> ||
<color>

<gap-repeat-rule> =
repeat( <integer [1,∞]> , <gap-rule># )

<line-width> =
<length [0,∞]> |
thin |
medium |
thick

<line-style> =
none |
hidden |
dotted |
dashed |
solid |
double |
groove |
ridge |
inset |
outset

示例

示例 1

css
/* 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;
}

示例 2

HTML

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

css
.content-box {
  padding: 0.3em;
  background: #ffff77;
  column-count: 3;
  column-rule: inset 2px #3333ff;
}

结果

规范

规范
CSS Multi-column Layout Module Level 1
# column-rule

浏览器兼容性

另见