js 鼠标跟随

 div { position: absolute;width: 10px;height: 10px;background: #f00;}

<script type="text/javascript">
    for (var i = 0; i < 10; i++) {
      var oDiv = document.createElement("div");
      document.body.appendChild(oDiv);
    }
    var aDiv = document.querySelectorAll("div");
    document.onmousemove = function (e) {
      var evt = e || event;
      var x = evt.clientX;
      var y = evt.clientY;
      aDiv[0].style.left = x + "px";
      aDiv[0].style.top = y + "px";
      for (var i = aDiv.length - 1; i >= 1; i--) {
        aDiv[i].style.left = aDiv[i - 1].style.left;
        aDiv[i].style.top = aDiv[i - 1].style.top;
      }
    }
  </script>

 

js 鼠标跟随

上一篇:css实现元素居中的几种方法


下一篇:unittest requests InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised.