• _鼠标移动跟随效果


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>_鼠标移动跟随效果</title>
    <style>
    div {
    50px;
    height: 50px;
    border-radius: 50%;
    position: absolute;
    text-align: center;
    font-size: 30px;
    color: #fff;
    }
    </style>
    <script>
    //让第一个盒子直接跟随鼠标位置
    //后面的盒子每隔几毫米跟随前一个盒子变化位置
    window.onload = function(){
    var allDiv = document.getElementsByTagName("div");//div数组
    document.onmousemove = function(e){
    e = e || window.event;//兼容性
    allDiv[0].style.top = e.clientY + "px";
    allDiv[0].style.left = e.clientX + "px";
    }
    //设置定时器
    setInterval(function(){
    for(var i=allDiv.length-1;i>0;i--){
    allDiv[i].style.top = allDiv[i-1].style.top;
    allDiv[i].style.left = allDiv[i-1].style.left;
    allDiv[i].style.backgroundColor = randomColor();
    }
    },20)
    //设置随机颜色
    function randomColor(){
    var str = "0123456789abcdef";
    var bgColor = "#";
    for(var i = 0;i<6;i++){
    var temp = parseInt(str.length*Math.random());
    bgColor += temp;
    }
    return bgColor;
    }
    }

    </script>



    </head>
    <body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    <div>7</div>
    <div>8</div>
    <div>9</div>
    <div>10</div>
    <div>11</div>
    <div>12</div>
    <div>13</div>
    <div>14</div>
    <div>15</div>
    <div>16</div>
    <div>17</div>
    <div>18</div>
    <div>19</div>
    <div>20</div>
    <div>21</div>
    <div>22</div>
    <div>23</div>
    <div>24</div>
    <div>25</div>
    <div>26</div>
    <div>27</div>
    <div>28</div>
    <div>29</div>
    <div>30</div>
    <div>31</div>
    <div>32</div>
    <div>33</div>
    <div>34</div>
    <div>35</div>
    <div>36</div>
    <div>37</div>
    <div>38</div>
    <div>39</div>
    <div>40</div>
    <div>41</div>
    <div>42</div>
    <div>43</div>
    <div>44</div>
    <div>45</div>
    <div>46</div>
    <div>47</div>
    <div>48</div>
    <div>49</div>
    <div>50</div>
    </body>
    </html>

  • 相关阅读:
    IDEA生成可执行的jar文件
    Android ROM包定制(解包,增删模块,打包)
    frida的用法--Hook Java代码篇
    C语言sprintf和sscanf函数用法
    C语言memcpy函数的用法
    自己动手编译Android(LineageOS)源码
    j2ee高级开发技术课程第三周
    linux内核学习之全局描述符表(GDT)(二)
    螺旋队列顺时针方向 和逆时针方向的实现
    zigzag数组:输入n,求一个nXn矩阵,规定矩阵沿45度递增,形成一个zigzag数组
  • 原文地址:https://www.cnblogs.com/R-jia-bao/p/6165863.html
Copyright © 2020-2023  润新知