有需求联系

Information

- 信息浏览 -

多页分页打印相关CSS

2026-04-14 12

<style>
    @media print {

        /* 全局打印设置 */
        @page {
            size: A4;
            /* 纸张:A4 / Letter */
            margin: 2cm 1.5cm;
            /* 页边距 */


            /* 页眉:顶部居中 */
            @top-center {
                content: "公司名称 - 报表标题";
                font-size: 12px;
                font-weight: bold;
                color: #333;
                border-bottom: 1px solid #999;
                padding-bottom: 3px;
            }

            /* 页脚 */
            @bottom-center {
                content: "第 " counter(page) " 页 / 共 " counter(pages) " 页";
                font-size: 12px;
                color: #333;
            }
        }

        /* thead 每页顶部重复显示 */
        thead {
            display: table-header-group;
        }

        /*每页底部重复显示*/
        tfoot {
            display: table-footer-group;
        }

        /* 禁止浏览器默认页眉页脚(URL/页码等)*/
        * {
            print-color-adjust: exact !important;
            -webkit-print-color-adjust: exact !important;
        }

        /* 强制分页 */
        .page-break {
            page-break-after: always !important;
            break-after: always !important;
        }

        /* 避免元素被分页撕裂 */
        .avoid-break {
            page-break-inside: avoid !important;
            break-inside: avoid !important;
        }

        /* 隐藏不需要打印的区域 */
        .no-print {
            display: none !important;
        }
        
        
         table {
         width: 100% !important;
         border-collapse: collapse;
        }

    }
</style>


Copyright © 2026 镇江小蚂蚁信息科技有限公司 All Rights Reserved.