column-rule

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Thuộc tính viết tắt column-rule CSS đặt độ rộng, kiểu dáng và màu sắc của đường kẻ được vẽ giữa các cột trong bố cục nhiều cột.

Try it

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;
}

Các thuộc tính thành phần

Thuộc tính này là thuộc tính viết tắt cho các thuộc tính CSS sau:

Cú pháp

css
column-rule: dotted;
column-rule: solid 8px;
column-rule: solid blue;
column-rule: thick inset blue;

/* Giá trị toàn cục */
column-rule: inherit;
column-rule: initial;
column-rule: revert;
column-rule: revert-layer;
column-rule: unset;

Giá trị

Thuộc tính column-rule được chỉ định là một, hai hoặc ba giá trị liệt kê bên dưới, theo bất kỳ thứ tự nào.

<'column-rule-width'>

<length> hoặc một trong ba từ khóa, thin, medium hoặc thick. Xem border-width để biết chi tiết.

<'column-rule-style'>

Xem border-style để biết các giá trị có thể và chi tiết.

<'column-rule-color'>

Là giá trị <color>.

Định nghĩa chính thức

Initial valueas each of the properties of the shorthand:
Applies tomulticol elements
Inheritedno
Computed valueas each of the properties of the shorthand:
Animation typeas each of the properties of the shorthand:

Cú pháp chính thức

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,∞]> |
hairline |
thin |
medium |
thick

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

<integer> =
<number-token>

Ví dụ

Ví dụ 1

css
/* Tương đương với "medium dotted currentColor" */
p.foo {
  column-rule: dotted;
}

/* Tương đương với "medium solid blue" */
p.bar {
  column-rule: solid blue;
}

/* Tương đương với "8px solid currentColor" */
p.baz {
  column-rule: solid 8px;
}

p.abc {
  column-rule: thick inset blue;
}

Ví dụ 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;
}

Kết quả

Thông số kỹ thuật

Specification
CSS Multi-column Layout Module Level 1
# column-rule

Tương thích trình duyệt

Xem thêm