• 跟随鼠标的天使


    图片放大镜用的就是这个思路

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>小天使跟随鼠标</title>
        <style>
            img {
                position: absolute;
            }
        </style>
    </head>
    <body>
    <img id="angel" src="image/angel.gif" alt="">
    <script>
        var img = document.getElementById('angel');
        //onmousemove 每移动1px就会触发
        img.addEventListener('mousemove', function (e) {
            var x = e.pageX;
            var y = e.pageY;
            img.style.left = x -50 + 'px';
            img.style.top = y -40 + 'px';
            //-50 -40 是让鼠标到图片的中间
        })
    </script>
    </body>
    </html>

    用到的图片

  • 相关阅读:
    带你走进Ajax
    基础
    基础
    基础-文字
    C++ part6.5
    操作系统 part4
    操作系统 part3
    计算机网络 part3 HTTP&HTTPS
    计算机网络 part2
    计算机网络 part1 TCP
  • 原文地址:https://www.cnblogs.com/fuyunlin/p/14446214.html
Copyright © 2020-2023  润新知