纯js+css实现手风琴

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

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

        body {
     
            background: #222222;
        }

        .view {
     
            margin: 100px auto;
            display: flex;
            width: 1200px;
        }

        .view .item {
     
            width: 100px;
            overflow: hidden;
            height: 260px;
            transition: all .2s;
        }

        .item div {
     
            text-align: center;
            background: rgba(0, 0, 0, 0.6);
            color: white;
            font-size: 30px;
            height: 260px;
            text-align: left;
            /* writing-mode: vertical-lr; */
            width: 400px;
            transition: all .2s;
        }

        .view .item1 {
     
            width: 400px;
            background: #ccc;
        }
    </style>
</head>

<body>
    <div class="view">
        <div class="item item1">
            <div>温泉酒店111</div>
        </div>
        <div class="item item2">
            <div>情侣酒店222</div>
        </div>
        <div class="item item3">
            <div>设计酒店333</div>
        </div>
        <div class="item item4">
            <div>青年旅舍444</div>
        </div>
        <div class="item item5">
            <div>特色客栈555</div>
        </div>
        <div class="item item6">
            <div>海岛酒店666</div>
        </div>
        <div class="item item7">
            <div>海外温泉777</div>
        </div>
    </div>
</body>

<script>
    console.log(9456789)
    window.onload = function () {
     
        var lis = document.querySelectorAll(".item");
        console.log(lis)
        for (let i = 0; i < lis.length; i++) {
     
            lis[i].onmouseenter = function () {
     
                for (var j = 0; j < lis.length; j++) {
     
                    lis[j].style.width = "100px";
                }
                lis[i].style.width = "400px";
            }
        }

    }

</script>

</html>

相关推荐

  1. js+css实现手风琴

    2023-12-12 12:28:03       57 阅读
  2. 手风琴效果(js)

    2023-12-12 12:28:03       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-12 12:28:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-12 12:28:03       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-12 12:28:03       82 阅读
  4. Python语言-面向对象

    2023-12-12 12:28:03       91 阅读

热门阅读

  1. linux常用命令-curl命令详解(超详细)

    2023-12-12 12:28:03       53 阅读
  2. LeetCode160. Intersection of Two Linked Lists

    2023-12-12 12:28:03       45 阅读
  3. GO设计模式——2、工厂方法模式(创建型)

    2023-12-12 12:28:03       61 阅读
  4. 利用playbook源码部署lamp

    2023-12-12 12:28:03       53 阅读
  5. 【APP安卓测试工具】adb(Android Debug Bridge)

    2023-12-12 12:28:03       41 阅读
  6. mysql分别在windows和linux下的备份策略

    2023-12-12 12:28:03       64 阅读
  7. TCP和UDP

    TCP和UDP

    2023-12-12 12:28:03      48 阅读
  8. zlib --- 与 gzip 兼容的压缩

    2023-12-12 12:28:03       54 阅读
  9. 微信小程序瀑布流组件

    2023-12-12 12:28:03       68 阅读
  10. YML学习

    2023-12-12 12:28:03       63 阅读
  11. linux缓冲区(buff/cache)内存占用过高解决办法

    2023-12-12 12:28:03       63 阅读
  12. SQL 存储过程&触发器

    2023-12-12 12:28:03       65 阅读
  13. 学习Node.js与Webpack总结

    2023-12-12 12:28:03       70 阅读