orphans
orphans 是一个 CSS 属性,用于设置在一个块容器中,必须显示在页面、区域或分栏底部最少的行数。
在排版中,孤行指的是一个段落的第一行单独出现在页面底部。(段落内容在下一页继续。)
语法
css
/* <integer> values */
orphans: 2;
orphans: 3;
/* Global values */
orphans: inherit;
orphans: initial;
orphans: revert;
orphans: revert-layer;
orphans: unset;
值
<integer>-
在分段断裂之前,在片段底部可以单独保留的最小行数。该值必须是正数。
正式定义
正式语法
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 |
浏览器兼容性
加载中…