Print
only?

前端 未结 30 2164
暖寄归人
暖寄归人 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:30

    Best css to fit space empty height:

    @media print {
      body * {
        visibility: hidden;
        height:0;
      }
      #section-to-print, #section-to-print * {
        visibility: visible;
        height:auto;
      }
      #section-to-print {
        position: absolute;
        left: 0;
        top: 0;
      }
    }
    

提交回复
热议问题