Phong cách góa phụ Tài sản
Ví dụ
Thay đổi góa phụ và kiểm tra bản in hoặc bản xem trước bản in:
<html>
<head>
<script>
function ChangeWidows()
{
document.getElementById("p1").style.widows = document.getElementById("widows").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
{
.widows
{
widows:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="widows" value="2">
<button onclick="ChangeWidows();">Change widows</button>
<p style="font-size:120%" id="p1">
Change widows 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>
<div class="othercontent">
</body>
</html>
Hãy tự mình thử »Sự miêu tả
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 (để in hoặc xem trước khi in).
Thuộc tính góa phụ chỉ ảnh hưởng đến các phần tử cấp khối.
Mẹo: góa phụ:5 có nghĩa là phải hiển thị ít nhất 5 dòng bên dưới ngắt trang.
Mẹo: Xem 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.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
widows | 25.0 | 8.0 | Not supported | 7.0 | 10.0 |
Cú pháp
Trả lại tài sản của góa phụ:
object .style.widows
Đặt thuộc tính góa phụ:
object .style.widows = "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 ở đầu trang |
Phiên bản CSS | CSS2 |