gpt4 book ai didi

html - Safari 打印不同于 Chrome + Firefox (html/css)

转载 作者:行者123 更新时间:2023-11-28 01:18:58 25 4
gpt4 key购买 nike

我正在尝试通过浏览器打印 avery 5160/8160 的条码表。我找到并修改了代码 https://boulderinformationservices.wordpress.com/2011/08/25/print-avery-labels-using-css-and-html/

它在 Firefox + Chrome 中的工作方式完全符合我的要求;但在 Safari 中,它在垂直和水平方向上都偏离中心打印。

是检测用户代理的唯一选择,并且只为 Safari 编写代码吗? Safari 是否有不同的英寸测量方法?

这是 chrome 的输出:

Chrome Chrome

这是 safari 的输出:

Safari Output

这里是使用的代码:

 <style>

@media print
{
html
{
margin: 0;
padding: 0;
}

body {
width: 8.5in !important;
margin: .5in .1875in 0 .1875in !important;
}

.hidden-print
{
display: none;
}

@page {
margin: 0;
padding: 0;
}
}


.barcode-label{
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
width: 2.325in;
height: 1.02in;
padding: .015in .15in 0 .15in;
margin-right: .195in;
font-size: 10pt;
float: left;
line-height: 1em;
letter-spacing: normal;

text-align: center;
overflow: hidden;

outline: 1px dotted;
}

.page-break {
clear: left;
display:block;
page-break-after:always;
}
</style>

<h1 class="hidden-print" style="text-align: center;">Avery 8160 <?php echo lang('common_template');?></h1>
<div class="hidden-print" style="text-align: center;margin-bottom: 10px;">
<button class="btn btn-primary text-white hidden-print" id="print_button" onclick="window.print();"><?php echo lang('sales_print'); ?></button>
</div>


<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

<div class='barcode-label'>PHP Point Of Sale, LLC<br />
<img src='http://home.chrismuench.com/phppos/PHP-Point-Of-Sale/index.php/barcode?barcode=0000000001&text=0000000001&scale=1' /><br />
<span style="font-size:12pt;">$11.20</span>: test
</div>

最佳答案

媒体打印未关闭

关于html - Safari 打印不同于 Chrome + Firefox (html/css),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34536436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com