Phong cách trẻ mồ côi Sở hữu
Thí dụ
Thay đổi trẻ mồ côi và kiểm tra bản in hoặc xem trước bản in:
<html>
<head>
<script>
function ChangeOrphans()
{
document.getElementById("p1").style.orphans = document.getElementById("orphans").value;
}
</script>
<style>
.othercontent
{
width: 400px;
border-top: 19cm solid #c3c3c3;
}
@page
{
/* set size of printed page */
size:21cm 27cm;
margin-top:2cm;
}
@media print
{
.orphans
{
orphans:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="orphans" value="2">
<button onclick="ChangeOrphans();">Change orphans</button>
<p style="font-size:120%" id="p1">
Change orphans and see the print preview.<br>
Line 2<br>
Line 3<br>
Line 4<br>
Line 5<br>
Line 6<br>
Line 7<br>
Line 8<br>
</p>
</body>
</html>
Hãy tự mình thử »
Định nghĩa và Cách sử dụng
Thuộc tính mồ côi đặt hoặc trả về số dòng tối thiểu cho một phần tử phải hiển thị ở cuối trang (để in hoặc xem trước bản in).
Thuộc tính mồ côi chỉ ảnh hưởng đến các phần tử cấp khối.
Mẹo: trẻ mồ côi: 5 có nghĩa là ít nhất 5 dòng phải hiển thị phía trên ngắt trang.
Mẹo: Xem thuộc tính widows để đặt hoặc trả về số dòng tối thiểu cho một phần tử phải hiển thị ở đầu trang.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
orphans | Yes | Not supported | Not supported | Not supported | Yes |
Cú pháp
Trả lại tài sản của trẻ mồ côi:
object.style.orphans
Đặt thuộc tính trẻ mồ côi:
object.style.orphans = "number|initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
number | An integer that specifies the minimum number of visible lines. Negative values are not allowed. The default value is 2 |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Chi tiết kỹ thuật
Giá trị mặc định: | 2 |
---|---|
Giá trị trả lại: | Một chuỗi, đại diện cho số dòng tối thiểu để in ở cuối trang |
Phiên bản CSS | CSS2 |
❮ Đối tượng phong cách