<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{width:10px;height:10px;border-radius: 50%;background-color: red;position: absolute;}
</style>
<script>
window.onload = function (){
var divs = document.getElementsByTagName("div");
document.onmousemove = function(ev){
var e = ev || window.event;
for(var i = divs.length -1 ; i >0 ; i--){
divs[i].style.left = divs[i-1].offsetLeft + "px";
divs[i].style.top = divs[i-1].offsetTop + "px";
}
divs[0].style.left = e.clientX + "px";
divs[0].style.top = e.clientY + "px";
}
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
跟随鼠标一串的效果
最新推荐文章于 2020-12-14 21:19:34 发布