﻿
@page {
    size: A4 portrait; /* a4尺寸 直式  */
    margin: 0.5cm; /* 邊距1公分 */
    orphans: 4; /* 頁面最後一段段落行數，預設值為2 */
    widows: 2; /* 頁面第一段段落行數，預設值為2  */
}


@media print {
    /* 很好的說明 https://kakadodo.github.io/2018/03/13/css-media-print-setting/  */
    /* https://medium.com/unalai/%E5%8E%9F%E4%BE%86%E5%89%8D%E7%AB%AF%E7%B6%B2%E9%A0%81%E5%88%97%E5%8D%B0-%E4%B8%8D%E6%98%AF%E5%8F%AA%E8%A6%81-window-print-%E5%B0%B1%E5%A5%BD%E4%BA%86-7af44cacf43e */
    /* 如果前端有加上 NotPrint，會發現只有在列印時才有作用 */
    .NotPrint {
        display: none;
    }
    .PageBreakAfter {

        page-break-after:always;
    }
    header nav, footer, video, audio, object, embed {
        display: none;
    }

    body {
        background: #fff; /* 列印模式背景用全白  */
        width: 100%;
        margin: 0;
        float: none;
        line-height: 1.5;
        font-size: 12pt;
    }

    img {
        max-width: 100%;
    }

    a:link, a:visited, a {
        background: transparent;
        color: #222;
        font-weight: bold;
        text-decoration: underline;
        text-align: left;
        word-wrap: break-word; /*避免網址過長超出頁面*/
    }

        a[href^="http://"]:after, a[href^="https://"]:after {
            content: " (" attr(href) ") ";
        }

    thead {
        display: table-header-group; /* 表格即使分頁也會顯示表頭 */
    }

    /* 以下是設定元素本身不要被分頁切開 */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

        h1 + p, h2 + p, h3 + p {
            page-break-before: avoid;
        }

    a {
        page-break-inside: avoid;
    }

    img {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    table, blockquote {
        page-break-inside: avoid;
    }

    ul, ol, dl {
        page-break-before: avoid;
    }
    /* 如架構本身用一組一組的 DIV 包住，也可強制設定每組 DIV 會各自切成一頁 */
    div.pageBlock {
        page-break-before: always;
    }
}

