Trigger resize event on print

前端 未结 2 1955
借酒劲吻你
借酒劲吻你 2021-01-04 07:50

I have a div in which I create a chart using protovis. The div has width: 100% and height: 100% and the code to create the chart uses $(\'#c

相关标签:
2条回答
  • 2021-01-04 08:09

    perhaps

    <style type="text/css">
          #chart { width: 100%; height: 100%; background: gray; border: 1px solid black;}
    </style>
    
    <style type="text/css" media="print">
          #chart { width: 100%; height: 98%; background: gray; border: 1px solid black;}
    </style>
    
    0 讨论(0)
  • 2021-01-04 08:22

    Rather than mutating the chart properties with an event, the @media print css rule might help here. https://developer.mozilla.org/en-US/docs/Web/CSS/%40media

    @media print{
      #chart { width: 100%; height: 98%; background: gray; border: 1px solid black;}
    }
    

    With this method, these style properties are applied on print, regardless what other changes you've made.

    0 讨论(0)
提交回复
热议问题