HTML DOM 스타일 속성을 과부
정의 및 사용
과부 속성 집합 또는 반환 페이지 표시 행의 상단 (인쇄 또는 인쇄 미리보기) 요소의 최소 수 있어야합니다.
과부 속성은 블록 수준 요소에 영향을 미칩니다.
팁 : 과부 : 5는 적어도 5 행이 페이지 나누기 아래에 표시해야한다는 것을 의미합니다.
팁 : 속성 세트를 고아또는 요소의 최소 수는 페이지 하단 라인에서 볼 수 있어야합니다 반환합니다.
문법
과부 속성 설정 :
Object.style.widows="number|inherit"
위로 특성을 과부 :
Object.style.widows
值 | 描述 |
---|---|
number | 一个规定可见行的最小数量的整数。默认值是 2。 |
inherit | widows 属性的值从父元素继承。 |
브라우저 지원
만 오페라는 과부 속성을 지원합니다.
예
예
인쇄를 변경하거나 인쇄 미리보기는 속성을 과부 :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>本教程(w3big.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>
»시도
스타일 개체