Style widows 屬性
- 上一頁 wordWrap
- 下一頁 zIndex
- 返回上一層 HTML DOM Style 對象
定義和用法
widows
屬性設置或返回必須在頁面頂部可見的元素的最小行數(用于打印或打印預覽)。
widows
屬性只影響塊級元素。
提示:widows:5
表示分頁符下方必須至少有 5 行可見。
提示:請參閱 orphans 屬性 以設置或返回必須在頁面底部可見的元素的最小行數。
實例
更改 widows 并檢查打印或打印預覽:
<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 { /* 設置打印頁面的大小 */ 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"> 更換 widows 并查看打印預覽。<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>
語法
返回 widows 屬性:
object.style.widows
設置 widows 屬性:
object.style.widows = "number|initial|inherit"
屬性值
值 | 描述 |
---|---|
number | 整數,規定最小可見行數。不允許使用負值。默認值為 2。 |
initial | 將此屬性設置為其默認值。請參閱 initial。 |
inherit | 從其父元素繼承此屬性。請參閱 inherit。 |
技術細節
默認值: | 2 |
---|---|
返回值: | 字符串,表示要在頁面頂部打印的最小行數。 |
CSS 版本: | CSS2 |
瀏覽器支持
表中的數字注明了首個完全支持該屬性的瀏覽器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
25.0 | 8.0 | 不支持 | 7.0 | 10.0 |
- 上一頁 wordWrap
- 下一頁 zIndex
- 返回上一層 HTML DOM Style 對象