实现一个鼠标跟随
<style> #pionter { width: 20px; height: 20px; background: pink; border-radius: 20px; position: absolute; } </style> <div id="pionter"></div> <script> window.onload = function () { var pionter = document.querySelector('#pionter'); window.onmousemove = function (e) { setTimeout(()=>{ pionter['style']['left'] = e.clientX-10 + 'px'; pionter['style']['top'] = e.clientY-10 + 'px'; },30) }; }; </script>