• js实现简易版放大镜(显示大图)


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

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;

        }

        ul,
        li {
            list-style: none;
        }

        ul {
             728px;
            height: 172px;
            margin: 0 auto;
        }

        li {
             172px;
            height: 172px;
            border: 1px solid black;
            float: left;
            margin: 5px;
        }

        .big {
             400px;
            height: 400px;
            border: 1px solid gray;
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }

        .big img {
             100%;
            height: 100%;
        }
    </style>

    <body>
        <ul>

            <li>
                <div>
                    <img src="./images/shirt_1.jpg">
                </div>
            </li>
            <li>
                <div>
                    <img src="./images/shirt_2.jpg">
                </div>
            </li>
            <li>
                <div>
                    <img src="./images/shirt_3.jpg">
                </div>
            </li>
            <li>
                <div>
                    <img src="./images/shirt_4.jpg">
                </div>
            </li>
        </ul>
        <div class="big">
            <img>
        </div>
    </body>

    </html>
    <script>
        var oli = document.querySelectorAll("ul li");
        var obox = document.querySelector(".big");
        console.log(obox.children[0]);
        for (let i = 0; i < oli.length; i++) {
            oli[i].onmousemove = function (e) {
                var e = e || event;
                obox.style.display = "block";//鼠标划在li上的时候让box显示
                obox.children[0].src = "./images/shirt_" + (i + 1) + ".jpg";
                obox.style.top = e.pageY + 10 + "px";//加10:让鼠标不要落在box的身上防止闪动
                obox.style.left = e.pageX + 10 + "px";
                e.stopprogation ? e.stopprogation() : e.cancelBubble = true;//document也添加了相同事件,阻止冒泡
            }
        }
        document.onmousemove = function () {
            obox.style.display = "none";
        }
    </script>
  • 相关阅读:
    restful接口设计规范总结
    SSM框架中,配置数据库连接的问题
    Java通过mysql-connector-java-8.0.11连接MySQL Server 8.0遇到的几个问题
    浅谈Spring的PropertyPlaceholderConfigurer
    过滤器与拦截器的区别
    SpringMVC的拦截器(Interceptor)和过滤器(Filter)的区别与联系
    SpringMVC中使用Interceptor拦截器
    mybatis中模糊查询的使用以及一些细节问题的注意事项
    mybatis generator(MyBatis的逆向工程)
    mybatis-generator生成逆向工程两种方式
  • 原文地址:https://www.cnblogs.com/bwnnxxx123/p/13052770.html
Copyright © 2020-2023  润新知