编辑下面的代码:【加编码】
<html> <head> <script> function ChangeOrphans() { document.getElementById("p1").style.orphans=document.getElementById("orphans").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 { .orphans { orphans:2; } } </style> </head> <body> <div class="othercontent"> <input id="orphans" value="2"> <button onclick="ChangeOrphans();">Change orphans</button> <p style="font-size:120%" id="p1"> Change orphans 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></body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂