实现效果如下:
HTML
<body>
<div class="box" id="box">
</div>
</body>
CSS
<style>
.box {
width: 800px;
height: 600px;
margin: 0 auto;
border: 2px solid #ccc;
position: relative;
}
</style>
JS
<script>
function cssHelper(el, prototype) {
for (let i in prototype) {
el.style[i] = prototype[i]
}
}
// 获取要放水印的box的宽高以及位置
const {
offsetLeft,
offsetTop,
clientWidth,