WaterMark水印

给页面的某个区域加上水印。
使用

何时使用#

  • 页面需要添加水印标识版权时使用。
  • 适用于防止信息盗用。

代码演示

最简单的用法。

expand codeexpand code
      加载中
    

通过 nzContent 设置 字符串数组 指定多行文字水印内容。

expand codeexpand code
      加载中
    

通过 nzImage 指定图片地址。为保证图片高清且不被拉伸,请设置 width 和 height, 并上传至少两倍的宽高的 logo 图片地址。

expand codeexpand code
      加载中
    

The light-speed iteration of the digital world makes products more complex. However, human consciousness and attention resources are limited. Facing this design contradiction, the pursuit of natural interaction will be the consistent direction of Ant Design.

Natural user cognition: According to cognitive psychology, about 80% of external information is obtained through visual channels. The most important visual elements in the interface design, including layout, colors, illustrations, icons, etc., should fully absorb the laws of nature, thereby reducing the user's cognitive cost and bringing authentic and smooth feelings. In some scenarios, opportunely adding other sensory channels such as hearing, touch can create a richer and more natural product experience.

Natural user behavior: In the interaction with the system, the designer should fully understand the relationship between users, system roles, and task objectives, and also contextually organize system functions and services. At the same time, a series of methods such as behavior analysis, artificial intelligence and sensors could be applied to assist users to make effective decisions and reduce extra operations of users, to save users' mental and physical resources and make human-computer interaction more natural.

示例图片

通过自定义参数配置预览水印效果。

expand codeexpand code
      加载中
    

API#

nz-water-mark#

参数说明类型默认值
nzContent水印文字内容string | string[]-
nzWidth水印的宽度,nzContent 的默认值为自身的宽度number120
nzHeight水印的高度,nzContent 的默认值为自身的高度number64
nzRotate水印绘制时,旋转的角度,单位 °number-22
nzZIndex追加的水印元素的 z-indexnumber9
nzImage图片源,建议导出 2 倍或 3 倍图,优先级高 (支持 base64 格式)string-
nzFont文字样式FontTypeFontType
nzGap水印之间的间距[number, number][100, 100]
nzOffset水印距离容器左上角的偏移量,默认为 nzGap/2[number, number][nzGap[0]/2, nzGap[1]/2]

FontType#

参数说明类型默认值
color字体颜色stringrgba(0,0,0,.15)
fontSize字体大小number16
fontWeight字体粗细normal | light | weight | numbernormal
fontFamily字体类型stringsans-serif
fontStyle字体样式none | normal | italic | obliquenormal

FAQ#

处理异常图片水印#

当使用图片水印且图片加载异常时,可以同时添加 nzContent 防止水印失效。

<nz-water-mark
  [nzWidth]="212"
  [nzHeight]="32"
  nzContent="NG Ant Design"
  nzImage="https://img.alicdn.com/imgextra/i3/O1CN01UR3Zkq1va9fnZsZcr_!!6000000006188-55-tps-424-64.svg"
>
  <div style="height: 500px"></div>
</nz-water-mark>