|
- <style>
- @media print {
- @page {
- size: A4 landscape !important; /*横向*/
- margin-left:5mm ;!important /*上下30mm页边距,左右20mm页边距*/
- }
- }
- body {
- background:white;
- font-size:.75em !important;
- margin: auto;
-
- }
- table {
- width: 97%!important;
- border-collapse: collapse;
- margin-left:3mm!important;
- margin-top:3mm;
- }
-
- table tbody th,
- table td {
- border: 1px solid black;
- }
- table th,
- table td {
- text-align: center;
- padding: 0px;
- }
- h1,
- h2,
- p {
- margin: 0;
- }
- h1, h2, h3, h4, h5, h6 { page-break-after:avoid;
- page-break-inside:avoid; }
-
-
- ul, ol, dl { page-break-before:avoid; }
- img { page-break-inside:avoid;
- page-break-after:avoid; }
- }
- </style>
复制代码
Js指定打印:
- bdhtml=window.document.body.innerHTML;
- sprnstr="<!--startprint-->";
- eprnstr="<!--endprint-->";
- prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
- prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
- window.document.body.innerHTML=prnhtml;
- window.print();
复制代码 |
|