Phong cách mồ côi tài sản
Ví dụ
Thay đổi trẻ mồ côi và kiểm tra bản in hoặc bản 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ử »Sự miêu tả
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: orphans:5 có nghĩa là phải hiển thị ít nhất 5 dòng phía trên ngắt trang.
Mẹo: Xem thuộc tính góa phụ để đặ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 | 25.0 | 8.0 | Not supported | 3.1 | 10.0 |
Cú pháp
Trả lại tài sản mồ côi:
object .style.orphans
Đặt thuộc tính 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ả về: | Một Chuỗi, thể hiện số dòng tối thiểu cần in ở cuối trang |
Phiên bản CSS | CSS2 |