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

瀏覽器相容性

另見