css set a4 paper size

本文详细介绍了一种使用HTML和CSS实现A4纸大小页面布局的方法,并通过具体示例展示了如何设置页面尺寸、边距、背景及阴影效果等,同时介绍了如何在打印时调整样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML

<div class="book">
    <div class="page">
        <div class="subpage">Page 1/2</div>    
    </div>
    <div class="page">
        <div class="subpage">Page 2/2</div>    
    </div>
</div>

CSS

body {
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    font: 12pt "Tahoma";
}
* {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
}
.page {
    width: 21cm;
    min-height: 29.7cm;
    padding: 2cm;
    margin: 1cm auto;
    border: 1px #D3D3D3 solid;
    border-radius: 5px;
    background: white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.subpage {
    padding: 1cm;
    border: 5px red solid;
    height: 256mm;
    outline: 2cm #FFEAEA solid;
}

@page {
    size: A4;
    margin: 0;
}
@media print {
    .page {
        margin: 0;
        border: initial;
        border-radius: initial;
        width: initial;
        min-height: initial;
        box-shadow: initial;
        background: initial;
        page-break-after: always;
    }
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <ureport xmlns="http://www.j2eefast.com/JUUreport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.j2eefast.com/JUUreport http://www.j2eefast.com/JUUreport "> <config> <name><![CDATA[资产标签打印]]></name> <downName><![CDATA[资产标签]]></downName> <func><![CDATA[_ALL]]></func> <roleKeys><![CDATA[_ALL]]></roleKeys> <tableAlias><![CDATA[,,]]></tableAlias> <remark><![CDATA[打印资产标签]]></remark> <version><![CDATA[V2.1-2022-06-01]]></version> </config> <cell col="1" expand="Down" name="A1" row="1"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle" wrap-compute="true"/> <dataset-value aggregate="select" dataset-name="assetList" mapping-type="simple" order="none" property="asset_id"/> </cell> <cell col="2" expand="None" name="B1" row="1"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"/> <simple-value/> </cell> <cell col="3" expand="None" name="C1" row="1"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"/> <simple-value/> </cell> <cell col="1" col-span="3" expand="None" left-cell="A1" name="A2" row="2"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <image-value height="60" source="text" width="260"> <text><![CDATA[/xdfz1.png]]></text> </image-value> </cell> <cell col="1" expand="None" left-cell="A1" name="A3" row="3"> <cell-style align="center" bold="false" font-size="10" forecolor="0,0,0" line-height="2" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <simple-value><![CDATA[单位]]></simple-value> </cell> <cell col="2" col-span="2" expand="None" left-cell="A1" name="B3" row="3"> <cell-style align="center" bold="false" font-family="宋体" font-size="10" forecolor="0,0,0" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <simple-value><![CDATA[0602 附属中学]]></simple-value> </cell> <cell col="1" expand="None" left-cell="A1" name="A4" row="4"> <cell-style align="center" bold="false" font-size="10" forecolor="0,0,0" line-height="2" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <simple-value><![CDATA[名称]]></simple-value> </cell> <cell col="2" col-span="2" expand="None" left-cell="A1" name="B4" row="4"> <cell-style align="center" bold="false" font-family="宋体" font-size="10" forecolor="0,0,0" line-height="2" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <dataset-value aggregate="group" dataset-name="assetList" mapping-type="simple" order="none" property="asset_name"/> </cell> <cell col="1" expand="None" left-cell="A1" name="A5" row="5"> <cell-style align="center" bold="false" font-family="宋体" font-size="9" forecolor="0,0,0" line-height="2" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <simple-value><![CDATA[规格]]></simple-value> </cell> <cell col="2" expand="None" left-cell="A1" name="B5" row="5"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <dataset-value aggregate="group" dataset-name="assetList" mapping-type="simple" order="none" property="specification"/> </cell> <cell col="3" expand="None" left-cell="A1" name="C5" row="5" row-span="2"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <zxing-value category="qrcode" height="85" source="expression" width="103"> <text><![CDATA[B6]]></text> </zxing-value> </cell> <cell col="1" expand="None" left-cell="A1" name="A6" row="6"> <cell-style align="center" bold="false" font-family="宋体" font-size="9" forecolor="0,0,0" line-height="2" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <simple-value><![CDATA[编号]]></simple-value> </cell> <cell col="2" expand="None" left-cell="A1" name="B6" row="6"> <cell-style align="center" font-family="宋体" font-size="9" forecolor="0,0,0" valign="middle"> <left-border color="0,0,0" style="solid" width="1"/> <right-border color="0,0,0" style="solid" width="1"/> <top-border color="0,0,0" style="solid" width="1"/> <bottom-border color="0,0,0" style="solid" width="1"/> </cell-style> <dataset-value aggregate="group" dataset-name="assetList" mapping-type="simple" order="none" property="asset_code"/> </cell> <row height="7" row-number="1"/> <row height="41" row-number="2"/> <row height="31" row-number="3"/> <row height="32" row-number="4"/> <row height="33" row-number="5"/> <row height="33" row-number="6"/> <column col-number="1" width="77"/> <column col-number="2" width="80"/> <column col-number="3" width="80"/> <datasource name="MASTER" type="buildin"> <dataset ispage="false" name="assetList" type="sql"> <sql><![CDATA[select asset_id, asset_name, asset_code, specification from am_asset where FIND_IN_SET(asset_id,:asset_ids)]]></sql> <field name="asset_id"/> <field name="asset_name"/> <field name="asset_code"/> <field name="specification"/> <parameter default-value="1912707435423539202,1912706746542661634" name="asset_ids" type="String"/> </dataset> </datasource> <paper bg-image="" bg-watermark="" bottom-margin="72" column-enabled="false" fixrows="0" height="842" html-interval-refresh-value="0" html-report-align="center" left-margin="90" orientation="portrait" paging-mode="fitpage" right-margin="90" top-margin="72" type="A4" width="595"/> </ureport> 这是ureport的xml
最新发布
07-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值