The effect of moving the mouse

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

</script>
<style type="text/css">
* {
padding: 0px;
margin: 0px;
}

.spandian {
background: black;
font-size: 0;
overflow: hidden;
width: 2px;
height: 2px;
position: absolute;
}
</style>
</head>
<body>
<span class='spandian' id="spandian">.</span>
</body>
</html>
<script type="text/javascript">
$(function () {
var count = 10;//设置个数
for (var i = 1; i < count * 8; i++) {
$("#spandian").after("<span class='spandian'>.</span>");
}
})
//移动效果
window.document.onmousemove = function (e) {
e = event || e;
var left = e.clientX;
var top = e.clientY;
move(top, left);
}
//给每一个span定义位置
function move (top, left) {
$ ( "spandian.") Each (function () {.
Var len = 10 * 1;
var = aqrt Math.sqrt (2) * 1;
var index = $ (this) .index () * 1;
var index j = parseInt (index / 8) * 1 + 1;
var indexZ = parseInt (index% 8) * 1 + 1;
var mtop = indexZ == 1 || indexZ == 5 0:? indexZ == 2 -indexJ * len / aqrt: indexZ == 3 -indexJ * len: indexZ == 4 -indexJ * len / aqrt:? indexZ == 6 index j * len / ? aqrt: indexZ == 8 index j * len / aqrt: index j * len;
var = mlef indexZ == 3 || indexZ == 7 0:? indexZ == 1 -indexJ * len: indexZ == 2 -indexJ? * len / aqrt: indexZ == 4 index j * len / aqrt: indexZ == 5 index j * len: indexZ == 8 -indexJ * len / aqrt: index j * len / aqrt;???
var ttop = mtop + top;
var llef = mlef + left;
var span = $(this)
setTimeout(function () { span.css({ top: ttop, left: llef }) }, index * 10)
})
}

</script>

Reproduced in: https: //www.cnblogs.com/-maomao/p/5015718.html

Guess you like

Origin blog.csdn.net/weixin_34008805/article/details/93760828