Stil-Eigenschaft 'widows'
- Vorherige Seite wordWrap
- Nächste Seite zIndex
- Zurück zur übergeordneten Ebene HTML DOM Style-Objekt
Definition und Verwendung
widows
Diese Eigenschaft setzt oder gibt die minimale Anzahl der sichtbaren Zeilen der Elemente zurück, die am oberen Rand der Seite sichtbar sein müssen (für Druck oder Druckvorschau).
widows
Diese Eigenschaft beeinflusst nur blockartige Elemente.
Tip:widows:5
Die folgenden 5 Zeilen müssen sichtbar sein, wenn der Seitentrenner angezeigt wird.
Tip:See orphans property to set or return the minimum number of lines that must be visible at the bottom of the page for an element.
Example
Change widows and check the print or print preview:
<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 the size of the print 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 view 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>
Syntax
Return widows property:
object.style.widows
Set widows property:
object.style.widows = "number|initial|inherit"
Attribute value
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. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | 2 |
---|---|
Return value: | A string that represents the minimum number of lines to be printed at the top of the page. |
CSS Version: | CSS2 |
Browser support
Die in der Tabelle genannten Zahlen geben die erste Version des Browsers an, die diese Eigenschaft vollständig unterstützt.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
25.0 | 8.0 | Nicht unterstützt | 7.0 | 10.0 |
- Vorherige Seite wordWrap
- Nächste Seite zIndex
- Zurück zur übergeordneten Ebene HTML DOM Style-Objekt