Style widowsプロパティ
Style オブジェクト
定義と使い方
widows プロパティは、要素がページの先頭に表示する必要がある最小の行数を設定または返します(印刷または印刷プレビュー用)。
widows プロパティはブロックレベル要素にのみ影響します。
ヒント:widows:5 は、少なくとも 5 行が改ページの下に表示されなければならないことを意味します。
ヒント:orphans プロパティは、要素がページの下部に表示する必要がある最小の行数を設定または返します。
構文
widows プロパティを設定:
Object.style.widows="number|inherit"
widows プロパティを返す:
Object.style.widows
| 值 | 説明 |
|---|---|
| number | 可視行の最小数を指定する整数。デフォルト値は 2 です。 |
| inherit | widows プロパティの値は親要素から継承されます。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
widows プロパティをサポートしているのは Opera のみです。
例
例
印刷または印刷プレビューの widows プロパティを変更:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<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();">ウィンドウを変更</button>
<p style="font-size:120%" id="p1">
ウィンドウを変更して印刷プレビューを表示<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"></div>
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<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();">ウィンドウを変更</button>
<p style="font-size:120%" id="p1">
ウィンドウを変更して印刷プレビューを表示<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"></div>
</div>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張