css - 是否可以在 css 文件中打印多个 @media
问题描述
我想在一个 CSS 文件中有 2 种不同的 @page 和 @media 打印样式。它也可以是分开的。为什么我需要 2 是我正在打印条形码,并且打印时页面需要不同的尺寸。目前正在发生的事情是它对两个条形码都使用样式 1 样式。如果它仅对Barcode1使用样式 1 样式,对Barcode2使用样式2,我该如何设置。
代码:CSS
**style 1**
@page { size: 8cm 3cm; margin-top: 16px; } /* output size */
body.receipt1 .sheet1 { width: 10cm; height: 3cm; margin-left: 35px; } /* sheet size */
@media print { body.receipt1 { width: 3cm } } /* fix for Chrome */
**style 2**
@page { size: 10cm 5cm; margin-top: 16px; } /* output size */
body.receipt2 .sheet2 { width: 12cm; height: 5cm; margin-left: 35px; } /* sheet size */
@media print { body.receipt2 { width: 5cm } } /* fix for Chrome */
条码1
<body className="receipt1">
<section className="sheet1">
<table className="table_b10">
<tbody>
<tr>
<td className="heading1_b10">Worksgroup</td>
</tr>
<tr>
<td className="heading2_b10">SKU: {this.props.stateInfo.itemName}</td>
</tr>
<tr>
<td className="heading2_b10">
<Barcode value={this.props.stateInfo.itemName} width={1} height={30} fontSize={0} margin={0} format="CODE128" />
</td>
</tr>
<tr>
<td className="heading2_b10">{this.props.stateInfo.itemDescription}</td>
</tr>
<tr>
<td className="heading2_bb10">LOG-ID: {this.props.audit.id}</td>
</tr>
</tbody>
</table>
</section>
</body>
条码2
<body class="receipt2">
<section class="sheet2">
<table className="table_b5">
<tbody>
<tr>
<td className="heading1_b5">Worksgroup</td>
</tr>
<tr>
<td className="heading2_b5">Job No\PO:</td>
</tr>
<tr>
<td className="heading3_b5">{this.props.job.jobNumber}</td>
</tr>
<tr>
<td className="heading2_b5">SKU:</td>
</tr>
<tr>
<td className="heading3_b5">{this.props.stateInfo.itemName}</td>
</tr>
<tr>
<td className="heading3_b5">
<Barcode value={this.props.stateInfo.itemName} width={0.75} height={25} fontSize={0} margin={0} format="CODE128" />
</td>
</tr>
<tr>
<td className="heading3_b5">{this.props.stateInfo.itemDescription}</td>
</tr>
<tr>
<td className="heading3b_b5">LOG-ID: {this.props.audit.id}
</td>
</tr>
</tbody>
</table>
</section>
</body>
解决方案
推荐阅读
- ssl - Certbot SSL 证书不起作用
- python - 在 pandasql 中使用字典值
- javascript - JavaScript Promise .then() 和 .catch 同时触发
- python - TypeError: urlopen() 在 Kubuntu 14.04 上通过 Selenium 和 Python 执行测试时获得了关键字参数“body”的多个值
- java-8 - 如何使用 Java 8 中的流 API 由同一类的不同对象填充数组列表?
- javascript - 从命令行程序计算价格
- r - 提取多个txt文档的第一行并在R中保存为元数据/向量
- java - 反射值未正确输出
- prestashop - 如何在 prestashoap 1.7 中传递变量 product.tpl 或 modal.tpl
- r - 使用 bookdown 时正确缩进列表项中的段落