前端开发效果圆点跟着鼠标走

b   前端开发软件
web前端常用开发软件下载
s打头的前端开发软件

html 代码

<!DOCTYPE html>
    <head>
        <meta charset=”utf-8″ />
        <title></title>
        <style>
            div {
                width: 10px;
                height: 10px;
                background: #7cfc00;
                position: absolute;
                border-radius: 5px;
            }
        </style>
        <script>
            for (var i = 0; i < 80; i++) {
                document.write(‘<div></div>’)
            }
            function getPos(ev) {
                var scrollTop =
                    document.documentElement.scrollTop ||
                    document.body.scrollTop
                var scrollLeft =
                    document.documentElement.scrollLeft ||
                    document.body.scrollLeft
                return { x: ev.clientX + scrollLeft, y: ev.clientY + scrollTop }
            }
            document.onmousemove = function(ev) {
                var aDiv = document.getElementsByTagName(‘div’)
                var oEvent = ev || event
                var pos = getPos(oEvent)
                for (var i = aDiv.length – 1; i > 0; i–) {
                    aDiv[i].style.left = aDiv[i – 1].offsetLeft + ‘px’
                    aDiv[i].style.top = aDiv[i – 1].offsetTop + ‘px’
                }
                aDiv[0].style.left = pos.x + ‘px’
                aDiv[0].style.top = pos.y + ‘px’
            }
        </script>
    </head>
    <body></body>
</html>
web前端开发 编程软件下载
软件前端开发晋升制度
前端开发编程软件
» 本文来自:前端开发者 » 《前端开发效果圆点跟着鼠标走》
» 本文链接地址:https://www.rokub.com/6931.html
» 您也可以订阅本站:https://www.rokub.com
赞(0)
64K

评论 抢沙发

评论前必须登录!