dongya4335 2019-05-04 04:36
浏览 620

使用CSS在多圈页面上打印动态文本水印

On the University system am developing. I supposed to generate admission letters where each letter has two pages with a dynamic diagonal student name . The problem is on printing the watermark comes to only one page instead of staying on each page yet on @media screen am achieving it.

<style>
@media screen{
#adm #background{
        position:absolute;
        z-index:0;
        display:block;
        height:850px;
        width:78%;
    }
    #adm #watermark{
        color:#f0f0f0;
        font-size:80px;
        transform:rotate(310deg);
        -webkit-transform:rotate(310deg);
    }
    #adm #content{
        position:relative;
        z-index:1;
    }
}

@media print{
#adm #background{
    position:fixed !important;
        z-index:-1;
        text-align:center;
        display:block;
        height:850px;
        width:78%;
        background:gre
    }
    #adm #watermark{

        color:#f0f0f0;
        font-size:70px;
        transform:rotate(310deg);
        -webkit-transform:rotate(310deg);
    }
    #adm #content{
        position:relative;
        z-index:1;
    }
}
</style>
<div id='adm'>
     <div id='background'>
        <div id='watermark'>John Morgan</div>
     </div>
     <div id='content'>Admission content</div>
</div>

I want when loop and print the admission text watermark of the student appears diagonally in the each admission letter.

  • 写回答

1条回答 默认 最新

  • duanquan1207 2019-05-04 05:25
    关注

    I think you need to set the position of your element from the top in your print media section and as many you want you can increase that. In your case, I set the .background CSS top:50%; and it shows the text in the middle of the page.

    And If you set it to top:150%; it will be shown in the second-page middle.

    @media print {
      .adm .background{
        position:fixed !important;
            z-index:-1;
            text-align:center;
            display:block;
            height:850px;
            width:78%;
            background:green;
        top:50%;
        }
    

    I provide an online demo for your requirements, please check here.

    https://codepen.io/nasser-ali-karimi/pen/MdgGoL

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器