横向手风琴–

鼠标悬浮某一张图片,图片显示,其他图片影藏。

<div class="content">
        <ul>
            <li class="current"><img src="./img4/1.jpg" alt="" height="400"></li>
            <li><img src="./img4/2.jpg" alt="" height="400"></li>
            <li><img src="./img4/3.jpg" alt="" height="400"></li>
            <li><img src="./img4/4.jpg" alt="" height="400"></li>
            <li><img src="./img4/5.jpg" alt="" height="400"></li>
        </ul>   
    </div>
<style>
        *{
            margin: 0;
            padding: 0;
        }
        .content {
            width: 1000px;
            height: 400px;
            margin: 100px auto;
            overflow: hidden;
            box-shadow: 0 0 2px 2px gray;
        }
        ul{
            width: 100%;
            height: 100%;
            list-style: none;
            display: flex;
        }
        li{
            width: 70px;
            height: 100%;
            overflow: hidden;
            transition: 0.5s;
        }
        .current{
            flex-grow: 10;
        }
    </style>
<script>
        let content = document.getElementsByClassName("content")[0];
        let lis = document.getElementsByTagName("li");


        let fn1 = function () {
            for(let i=0;i<lis.length;i++){
                lis[i].className = "";
            }
            this.className = "current";
        }

        for (let i = 0; i < lis.length; i++) {
            lis[i].addEventListener("mouseenter", fn1, "false");
        }
    </script>

 

版权声明:本文为CccK-html原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/CccK-html/p/11582497.html