此为鼠标拖拽效果,多用于放大视图 用js展示出来
示图:

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#box {
width: 300px;
height: 400px;
background-color: bisque;
position: absolute;
}
</style>
</head>
<body>
<div id="box"></div>
<script>
//获取标签
let box = document.getElementById("box")
//当鼠标松开时div的位置
box.onmousedown = function (e) {
let ox = e.offsetX
let oy = e.offsetY
//浏览器窗口
document.onmousemove = function (e2) {
let cx = e2.clientX
let cy = e2.clientY
let _left = cx - ox
let _top = cy - oy
//浏览器不能移出左边框
if (_left < 0) {
_left = 0
}
//不能移出浏览器上边框
if (_top < 0) {
_top = 0
}
//不能移出浏览器右边框和下边框
if (_left > document.documentElement.clientWidth - box.offsetWidth) {
_left = document.documentElement.clientWidth - box.offsetWidth
}
if (_top > document.documentElement.clientHeight - box.offsetHeight) {
_top = document.documentElement.clientHeight - box.offsetHeight
}
box.style.left = _left + "px"
box.style.top = _top + "px"
}
}
document.onmouseup = function () {
document.onmousemove = null
}
</script>
</body>
</html>