简体   繁体   English

在 html/css 中打印标签突然中断

[英]Printing labels in html/css broke suddenly

I have a printing page in a website that prints labels for shoes as the picture shows.如图所示,我在一个网站上有一个打印页面,可以打印鞋子的标签。 This had been working for more than 3 years.这已经工作了3年多。 Two days ago, this broke as shown, the labels or page-break-after stopped working properly.两天前,如图所示,标签或分页符停止正常工作。

I looked online but could not know what went wrong.我在网上看了,但不知道出了什么问题。

The correct behaviour is to view each label in a page, so the label printer can print it correctly.正确的行为是在一个页面中查看每个 label,这样 label 打印机才能正确打印。

Code: CSS代码:CSS

 h1, h3, h2, h4 { margin-bottom: 1px; } h6 { margin: 0px; direction: ltr; }.col-4, .col-2, .col-8 { padding: 1px; } @page { size: 10cm 5cm; margin: 0.2cm; } img { width: 95%; height: 60px; } p.att-value { font-family: 'Almarai', sans-serif; font-size: larger; margin: 0; padding: 2px; } span.value-block { background-color: black; color: white; padding: 5px; }.a-label { height: 10cm; width: 5cm; padding-top: 5px; padding-right: 30px; margin-bottom: 0.1cm; } @media print{ html, body { width: 10cm; height: 5cm; }.pagebreak { break-inside: avoid; break-after: page; } }
 <div class="a-label"> <div class="row"> <div class="col-12 text-center"> <img src="https://i.stack.imgur.com/FxCHC.png"> <h6>123456</h6> </div> </div> <div class="row"> <div class="col-12"> <h3>Shoe Name</h3> <p class="att-value"> <span class="value-block">Product Name</span> <span class="value-block">Size: 36</span> <span class="att-value"> 250 usd</span> </p> </div> </div> </div> <div class="pagebreak"></div> <div class="a-label"> <div class="row"> <div class="col-12 text-center"> <img src="https://i.stack.imgur.com/FxCHC.png"> <h6>123456</h6> </div> </div> <div class="row"> <div class="col-12"> <h3>Shoe Name 2</h3> <p class="att-value"> <span class="value-block">Product Name</span> <span class="value-block">Size: 36</span> <span class="att-value"> 250 usd</span> </p> </div> </div> </div> <div class="pagebreak"></div>

This feature broke on all browsers这个功能在所有浏览器上都失效了

它曾经是单独页面中的每个标签

It worked after I updated to the latest bootstrap, specifically version 5. It is unclear to me why it broke suddenly.在我更新到最新的引导程序(特别是第 5 版)后它就起作用了。我不清楚它为什么突然坏了。 This feature worked 3 years.此功能工作了 3 年。

So, the comment from @AndrewMorton was helpful.所以,@AndrewMorton 的评论很有帮助。 The credit goes to him.功劳归于他。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM