1. 水印图片生成采用svg,这样可以运行时生成名字或其他信息的图片

svg模板

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300px" height="160px" viewBox="0 0 300 160">
<text x="-100" y="-30" fill='#000' transform = "rotate(-35 240 -200)" fill-opacity='0.03' font-size='40'>I love SVG</text>
</svg>

一定要记得设置透明度(fill-opacity),否则水印会遮挡正文

svg需要转码: https://codepen.io/huashiyiqike/pen/rERBeJ

2. 通过css覆盖在整个页面上

水印元素放到页面大小的容器的最后面

父元素:
position: relative;
水印元素
position: absolute;
top: 0;
bottom: 0; // 整体覆盖
left: 0;
width: 100%;
height: 100%;
z-index: 100;
pointer-events: none; // 对鼠标穿透

3. 通过js拼接svg,并写入模板或者html

js: 
this.watermarkstyle = `background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='200px' height='160px' viewBox='0 0 200 160'%3E %3Ctext x='-100' y='-30' fill='%23000' transform = 'rotate(-35 240 -200)' fill-opacity='0.04' font-size='40'%3E${
this.$store.state.authUser.username
}%3C/text%3E %3C/svg%3E ")` html:
<div class="watermark" :style="watermarkstyle"></div>

最新文章

  1. 手机端访问web调用数字键盘。
  2. bat转exe工具 Bat To Exe Converter v2.4.7 绿色版
  3. 第5章 LINQ
  4. php操作xml
  5. SQL Server中关于跟踪(Trace)那点事
  6. I2C实时时钟rx-8025板卡实际应用
  7. 设计模式(4) -- 单例模式(Singleton)
  8. dede取得指定栏目的链接
  9. 2016.08.13/2/index/_d_Lucene54_0.dvm: Too many open files
  10. cocos2d-x3.0 lua学习(一个)
  11. python 保存文本txt格式之总结篇,ANSI,unicode,UTF-8
  12. k-选取问题
  13. linux centos6.5安装KVM
  14. Abstract与Virtual
  15. js通過name获取input框输入值
  16. Navicat MySQL 自动备份
  17. OAF 抛出html消息
  18. luogu1541 乌龟棋 (dp)
  19. SpringCloud入门之Maven系统安装及配置
  20. 更加灵活的编写控制层的方法____结合eval函数

热门文章

  1. IE haslayout 问题引起的常见 bug
  2. nodejs中判断请求来自PC端还是移动端
  3. file size php
  4. can总线学习网上资料汇总
  5. str2int HDU - 4436 (后缀自动机)
  6. React渲染和事件处理
  7. fork和vfork
  8. SpringBoot2.0给所有Controller添加统一前缀
  9. Net core学习系列(七)——Net Core中间件
  10. 《微信小程序商城开发实战》笔者的新书,欢迎各位粉丝上京东购买