Print
only?

前端 未结 30 1643
暖寄归人
暖寄归人 2020-11-22 00:25

How do I print the indicated div (without manually disabling all other content on the page)?

I want to avoid a new preview dialog, so creating a new window with this

30条回答
  •  灰色年华
    2020-11-22 00:45

    I found the solution.

    @media print {
        .print-area {
            background-color: white;
            height: 100%;
            width: auto;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            z-index:1500;
            visibility: visible;
        }
        @page{
            size: portrait;
            margin: 1cm;
        }
    /*IF print-area parent element is position:absolute*/
        .ui-dialog,
        .ui-dialog .ui-dialog-content{
            position:unset !important;
            visibility: hidden;
        }
    }
    

提交回复
热议问题