You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

需求:构建多层级分类的HTML工作说明PNG文件索引工具

纯前端多级折叠菜单工具:快速打开分类PNG文件

这事儿太适合用纯前端方案解决了!不用装任何框架,本地直接用浏览器打开就能跑,完美匹配你的多级分类需求。我给你写个完整的可直接复用的示例,你改改分类名称和图片路径就能用:

第一步:整理你的文件结构

先把PNG按分类整理成层级文件夹,这样路径好写也不容易乱,比如:

工作说明图片工具/
├─ index.html       ← 我们要写的HTML文件
├─ 集合1/
│  ├─ 选项1/
│  │  ├─ 1.1.png
│  │  ├─ 1.2.png
│  │  └─ 1.3.png
│  ├─ 选项2/
│  │  ├─ 2.1.png
│  │  └─ 2.2.png
│  └─ 选项3/
│     └─ ...
├─ 集合2/
│  ├─ 选项A/
│  │  └─ ...
│  └─ 选项B/
│     └─ ...
└─ 集合X/
   └─ ...

第二步:复制以下代码到index.html

这个代码包含了折叠菜单的样式、交互逻辑,还有示例的分类结构,你直接替换成自己的内容就行:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>工作说明图片快速查询</title>
    <style>
        /* 基础样式,让界面更美观 */
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 20px auto;
            padding: 0 20px;
            background-color: #f5f5f5;
        }
        .collection {
            margin: 10px 0;
            background-color: white;
            border-radius: 4px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .collection-title {
            padding: 12px 15px;
            font-weight: bold;
            cursor: pointer;
            background-color: #e8f0fe;
            border-radius: 4px 4px 0 0;
        }
        .options-container {
            padding: 0 15px;
            display: none; /* 默认隐藏子菜单 */
        }
        .option {
            margin: 8px 0;
            padding-left: 10px;
            border-left: 2px solid #ccc;
        }
        .option-title {
            padding: 8px 0;
            font-weight: 500;
            cursor: pointer;
            color: #2c3e50;
        }
        .sub-items-container {
            padding-left: 20px;
            display: none; /* 默认隐藏子项 */
        }
        .sub-item {
            margin: 5px 0;
        }
        .sub-item a {
            color: #3498db;
            text-decoration: none;
        }
        .sub-item a:hover {
            text-decoration: underline;
        }
        /* 展开状态的样式 */
        .expanded {
            display: block !important;
        }
    </style>
</head>
<body>
    <h1>工作说明图片查询工具</h1>

    <!-- 集合1示例 -->
    <div class="collection">
        <div class="collection-title" onclick="toggleMenu(this, '.options-container')">集合1</div>
        <div class="options-container">
            <!-- 选项1示例 -->
            <div class="option">
                <div class="option-title" onclick="toggleMenu(this, '.sub-items-container')">选项1</div>
                <div class="sub-items-container">
                    <div class="sub-item"><a href="集合1/选项1/1.1.png" target="_blank">1.1 某工作说明图</a></div>
                    <div class="sub-item"><a href="集合1/选项1/1.2.png" target="_blank">1.2 某工作说明图</a></div>
                    <div class="sub-item"><a href="集合1/选项1/1.3.png" target="_blank">1.3 某工作说明图</a></div>
                </div>
            </div>
            <!-- 选项2示例 -->
            <div class="option">
                <div class="option-title" onclick="toggleMenu(this, '.sub-items-container')">选项2</div>
                <div class="sub-items-container">
                    <div class="sub-item"><a href="集合1/选项2/2.1.png" target="_blank">2.1 某工作说明图</a></div>
                    <div class="sub-item"><a href="集合1/选项2/2.2.png" target="_blank">2.2 某工作说明图</a></div>
                </div>
            </div>
        </div>
    </div>

    <!-- 集合2示例 -->
    <div class="collection">
        <div class="collection-title" onclick="toggleMenu(this, '.options-container')">集合2</div>
        <div class="options-container">
            <div class="option">
                <div class="option-title" onclick="toggleMenu(this, '.sub-items-container')">选项A</div>
                <div class="sub-items-container">
                    <div class="sub-item"><a href="集合2/选项A/A1.png" target="_blank">A1 某工作说明图</a></div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 切换菜单展开/折叠的函数
        function toggleMenu(trigger, targetClass) {
            const target = trigger.nextElementSibling;
            target.classList.toggle('expanded');
        }
    </script>
</body>
</html>

第三步:修改成你自己的内容

  1. 替换集合名称:把所有<div class="collection-title">里的文本(比如“集合1”“集合2”)换成你的实际集合名
  2. 替换选项名称:修改<div class="option-title">里的文本(比如“选项1”“选项A”)
  3. 替换图片路径和说明:修改<a>标签的href为你的PNG文件的相对路径,同时把<a>里的文本换成对应的图片说明(比如“1.1 登录流程说明”)

第四步:使用工具

直接双击index.html文件,用浏览器打开就行!点击集合名称展开选项,点击选项名称展开子项,再点击子项链接就能在新窗口打开对应的PNG图片了。

小技巧

如果你的分类和图片特别多,手动写HTML太麻烦,可以用Excel整理好集合名、选项名、子项说明、图片路径,然后用Excel的公式批量生成HTML代码片段,再粘贴到上面的文件里,能省超多时间!

内容的提问来源于stack exchange,提问作者tropical e

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:36:19