<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #a {
            width: 200px;
            height: 30px;
            border: 1px solid #000;
            text-align: center;
            list-style: none;
            background-color: pink;
        }

        #b {
            width: 200px;
            height: 230px;
            border: 1px solid #000;
            text-align: center;
            list-style: none;
            background-color: pink;
        }

        #ula {
            position: absolute;
        }
    </style>
</head>

<body>
    <ul id="ula">
        <li id="a">目录</li>
        <li id="b">内容</li>
    </ul>
    <!-- <div id="ula"></div> -->
    <script>
        var ula = document.querySelector("#ula")

        document.addEventListener("mousemove", function (e) {
            var x = e.pageX
            var y = e.pageY
            ula.style.left = x - 130 + "px";
            ula.style.top = y - 130 + "px";

        })
    </script>
</body>

</html>
内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/huwenlong/p/17287795.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!