Cell Watermark
Create watermark for webpage and automatic adjust when window resize.
目录
注意
本文最后更新于 2023-10-11,文中内容可能已过时。
Usage
1 Browser
Clone source
1
git clone git@github.com:Lruihao/watermark.git
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>
Initialization
1 2 3 4 5
document.addEventListener('DOMContentLoaded', function () { new Watermark({ content: "cell-watermark" }) });
2 NPM
Install
1
npm i cell-watermark
Import
1 2 3
import Watermark from 'cell-watermark' /* Or */ var Watermark = require("cell-watermark")
Class: Watermark
1 Watermark(options)
1.0.1 new Watermark(options)
1.0.1.1 Parameters
Name | Type | Description |
---|---|---|
options | Object | The options of watermark(Properties) |
1.0.1.1.1 Properties
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
content | String | <optional> | watermark’s text | |
appendTo | String | <optional> | ‘body’ | parent of watermark’s container |
width | Number | <optional> | 150 | watermark’s width. unit: px |
height | Number | <optional> | 20 | watermark’s height. unit: px |
rowSpacing | Number | <optional> | 60 | row spacing of watermarks. unit: px |
colSpacing | Number | <optional> | 30 | col spacing of watermarks. unit: px |
rotate | Number | <optional> | 15 | watermark’s tangent angle. unit: deg |
opacity | Number | <optional> | 0.1 | watermark’s transparency |
fontSize | Number | <optional> | 0.85 | watermark’s fontSize. unit: rem |
fontFamily | String | <optional> | ‘inherit’ | watermark’s fontFamily |
Author: Lruihao
1.1 Methods
1.1.1 upload(content)
Upload watermark’s text content
1.1.1.1 Parameters
Name | Type | Description |
---|---|---|
content | String | watermark’s text |
1.1.2 render(options)
Rerender watermark
1.1.2.1 Parameters
Name | Type | Description |
---|---|---|
options | Object | The options of watermark(Properties) |
1.1.3 destroy()
Force destroy watermark
相关内容
Buy me a coffee~
支付宝
微信