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

浏览器兼容性

另见