2020-11-24给页面加水印

给页面加水印

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>水印处理</title>
  <style type="text/css">
    header {
      height: 50px;
      border-bottom: 1px solid #ddd;
      box-sizing: border-box;
    }
    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
    }
    .water-mark {
      position: fixed;
      left: 0;
      top: 50px;
      right: 0;
      bottom: 0;
      z-index: 99999; /**尝试修改为-1试试*/
      pointer-events: none; /**key words*/
    }
  </style>
</head>
<body>
  <div class="water-mark">

  </div>
  <header>
    <h3>加水印-当前时间和名字</h3>
  </header>
  <div class="content">

    <div class="text-wrapper">
      <span>这里是内容区</span>
    </div>
    
  </div>
  <script typee="text/javascript">
      let name = 'Kevin'
      let date = '2019-11-20'
      var background = "url(\"data:image/svg+xml;utf8,"+
          "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='130' width='130'>" +
            "<text text-anchor='middle' transform='rotate(-20)' font-weight='bold' fill='rgba(221, 221, 221, .7)' font-size='14' >" + 
              "<tspan x='50' y='50'>"+ name +" </tspan>" +
              "<tspan x='50' y='65'>"+ date +" </tspan>" +
            "</text>"+
          "</svg>\")";  

      let domObj = document.getElementsByClassName('water-mark')[0]
      domObj.style.backgroundImage= background;
  </script>
</body>
</html>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值