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

浏览器兼容性

另见