<style>
div {
position: absolute;
width: 200px;
height: 50px;
background-color:pink;
}
</style>
<script>
//div盒子可以跟着鼠标走
var div = document.querySelector('div')
document.addEventListener('mousemove',function(e){
var x=e.pageX
var y=e.pageY
div.style.top =y-25+'px'
div.style.left =x-100+'px'
})
</script>