Cell Watermark

Create watermark for webpage and automatic adjust when window resize.

警告
本文最后更新于 2023-07-07,文中内容可能已过时。

Usage

Browser

  1. Clone source

    1
    
    git clone git@github.com:Lruihao/watermark.git
  2. Load Watermark

    1
    2
    3
    4
    5
    
    <script type="text/javascript" src="./src/watermark.js"></script>
    <script type="text/javascript" src="./src/watermark.min.js"></script>
    <!-- Or CDN -->
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cell-watermark@1.0.3/src/watermark.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cell-watermark@1.0.3/src/watermark.min.js"></script>
  3. Initialization

    1
    2
    3
    4
    5
    
    document.addEventListener('DOMContentLoaded', function () {
      new Watermark({
        content: "cell-watermark"
      })
    });

NPM

  1. Install

    1
    
    npm i cell-watermark
  2. Import

    1
    2
    3
    
    import Watermark from 'cell-watermark'
    /* Or */
    var Watermark = require("cell-watermark")

Class: Watermark

Watermark(options)

new Watermark(options)

Parameters:
NameTypeDescription
optionsObjectThe options of watermark(Properties
Properties:
NameTypeAttributesDefaultDescription
contentString<optional>watermark’s text
appendToString<optional>‘body’parent of watermark’s container
widthNumber<optional>150watermark’s width. unit: px
heightNumber<optional>20watermark’s height. unit: px
rowSpacingNumber<optional>60row spacing of watermarks. unit: px
colSpacingNumber<optional>30col spacing of watermarks. unit: px
rotateNumber<optional>15watermark’s tangent angle. unit: deg
opacityNumber<optional>0.1watermark’s transparency
fontSizeNumber<optional>0.85watermark’s fontSize. unit: rem
fontFamilyString<optional>‘inherit’watermark’s fontFamily

Author: Lruihao

Methods

upload(content)

Upload watermark’s text content

Parameters:
NameTypeDescription
contentStringwatermark’s text

render(options)

Rerender watermark

Parameters:
NameTypeDescription
optionsObjectThe options of watermark(Properties

destroy()

Force destroy watermark

Buy me a coffee~
支付宝
微信
0%