orphans

可用性有限

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

orphans 是一個 CSS 屬性,用於設定在一個塊容器中,必須顯示在頁面、區域或分欄底部最少的行數。

在排版中,孤行指的是一個段落的第一行單獨出現在頁面底部。(段落內容在下一頁繼續。)

語法

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

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

<integer>

在分段斷裂之前,在片段底部可以單獨保留的最小行數。該值必須是正數。

正式定義

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

正式語法

orphans = 
<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 orphans 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;
  height: 150px;
  columns: 3;
  orphans: 3;
}

p {
  background-color: #8ca0ff;
}

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

結果

規範

規範
CSS Fragmentation Module Level 3
# widows-orphans

瀏覽器相容性

另見