widows

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

widows CSS 屬性設定塊容器中,必須顯示在頁面、區域或頂部的最小行數。

在排版中,“widow” 是指段落的最後一行,它單獨出現在頁面的頂部。(該段落是從前一頁延續下來的。)

語法

css
/* <integer> values */
widows: 2;
widows: 3;

/* Global values */
widows: inherit;
widows: initial;
widows: revert;
widows: revert-layer;
widows: unset;

<integer>

在分段符後,可以單獨留在新片段頂部的最小行數。該值必須為正數。

正式定義

初始值2
應用於塊容器元素
繼承性
計算值同指定值
動畫型別按計算值型別

正式語法

widows = 
<integer [1,∞]>

示例

控制列中的孤行

HTML

html
<div>
  <p>This is the first paragraph containing some text.</p>
  <p>
    This is the second paragraph containing some more text than the first one.
    It is used to demonstrate how widows work.
  </p>
  <p>
    This is the third paragraph. It has a little bit more text than the first
    one.
  </p>
</div>

CSS

css
div {
  background-color: #8cffa0;
  columns: 3;
  widows: 2;
}

p {
  background-color: #8ca0ff;
}

p:first-child {
  margin-top: 0;
}

結果

規範

規範
CSS Fragmentation Module Level 3
# widows-orphans
CSS Multi-column Layout Module Level 1
# filling-columns

瀏覽器相容性

另見