Repeating a watermark on every print page? Javascript or css

后端 未结 2 1165
夕颜
夕颜 2020-12-18 22:12

So, I have this Invoice page. and i am adding a watermark behind the page. i need to repeat the watermark for each page that would be printed.

The problem is that, I

相关标签:
2条回答
  • 2020-12-18 22:44

    I would consider an overlay with a background that you repeat each 100vh. You can activate this style only on print using media query.

    I used SVG for simplicity, you can easily replace with an image.

    body {
      min-height: 300vh;
      position: relative;
      margin: 0;
    }
    
    body:before {
      content: "";
      position: absolute;
      z-index: 9999;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background: 
        url('data:image/svg+xml;utf8,<svg style="transform:rotate(-45deg)" xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 50 60"><text x="0" y="25" fill="%23000">Lorem </text></svg>') 
        0 0/100% 100vh;
    }

    0 讨论(0)
  • 2020-12-18 22:46

    take watermark as background image

    <style type="text/css" media="print">
        .content-box
        {
            background-image:url('watermarkimage.png');
            background-repeat:repeat-y;
            background-position: center;
            background-attachment:fixed;
            background-size:100%;
        }
    </style>
    
    0 讨论(0)
提交回复
热议问题