Web前端需要连接热敏打印机打印小票,但是font-size始终无法调小,最终解决见demo:
update:2020年12月04日
https://medium.com/@Idan_Co/the-ultimate-print-html-template-with-header-footer-568f415f6d2a
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <!DOCTYPE HTML> <html>
<head> <meta name="renderer" content="webkit"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>美问</title> <style type="text/css"> @media screen { #printSection { display: none; } } @page { margin: 0cm; } @media print { body * { visibility: hidden; } #printSection * { visibility: visible; } p { font-size: 9pt; } h4 { font-size: 18pt; } } </style> <script type="text/javascript"> function printTest() { window.print(); }
</script> </head>
<body> <div> <div id="printSection"> <div style="width: 150%;height: 1px;"></div> <p>打印测试</p> <h4>打印测试</h4> </div> <button onclick="printTest()">打印</button> </div> </body>
</html>
|