From 1032cbabf52a5e0ed8542114832cafd91a96f8b9 Mon Sep 17 00:00:00 2001 From: yiqiu Date: Sat, 10 Jan 2026 18:12:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common.js | 6 ++-- css/nav-mega-menu.css | 72 +++++++++++++++++++++++++++++++++++++++++-- public/header.html | 18 ++++++----- 3 files changed, 84 insertions(+), 12 deletions(-) diff --git a/common/common.js b/common/common.js index 268d80a..e163b51 100644 --- a/common/common.js +++ b/common/common.js @@ -130,9 +130,11 @@ $(function () { let hoverTimer = null; let leaveTimer = null; - $(".nav-menu .nav-item").hover( + // 只监听 .nav-menu 内部的 .nav-item,排除LOGO等其他元素 + $(".nav-menu > a .nav-item, .nav-menu > .nav-item").hover( function () { - const index = $(".nav-menu .nav-item").index($(this)); + // 获取当前nav-item在nav-menu中的索引 + const index = $(".nav-menu > a .nav-item, .nav-menu > .nav-item").index($(this)); // 清除离开定时器 if (leaveTimer) { diff --git a/css/nav-mega-menu.css b/css/nav-mega-menu.css index 0fe2263..94451a7 100644 --- a/css/nav-mega-menu.css +++ b/css/nav-mega-menu.css @@ -11,7 +11,8 @@ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); border-top: 1px solid rgba(56, 189, 248, 0.15); z-index: 1000; - overflow: hidden; + overflow-x: hidden; + overflow-y: hidden; transition: height 0.3s ease-out; height: 0; } @@ -90,6 +91,7 @@ flex: 1; padding: 16px 24px; background: rgba(15, 23, 42, 0.6); + overflow-x: hidden; overflow-y: auto; max-height: none; height: 100%; @@ -187,8 +189,74 @@ font-size: 14px; } -/* 旧版二级菜单样式(无三级菜单时使用) */ +/* 只有二级菜单时的横向网格布局 */ +.nav-simple-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + gap: 16px; + padding: 24px 32px; + max-width: 1400px; + margin: 0 auto; +} + +.nav-simple-item { + display: flex; + align-items: center; + gap: 12px; + padding: 16px; + background: rgba(30, 41, 59, 0.6); + border: 1px solid rgba(56, 189, 248, 0.15); + border-radius: 6px; + color: #E5E7EB; + text-decoration: none; + transition: all 0.2s ease; +} + +.nav-simple-item:hover { + background: rgba(56, 189, 248, 0.15); + border-color: #38BDF8; + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2); +} + +.nav-simple-icon { + width: 32px; + height: 32px; + flex-shrink: 0; +} + +.nav-simple-icon img { + width: 100%; + height: 100%; + object-fit: contain; +} + +.nav-simple-info { + flex: 1; + min-width: 0; +} + +.nav-simple-title { + font-size: 14px; + font-weight: 600; + color: #E5E7EB; + margin-bottom: 4px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.nav-simple-desc { + font-size: 12px; + color: #94A3B8; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +/* 旧版二级菜单样式(无三级菜单时使用) - 已废弃,保留兼容 */ .nav-item-box { + display: flex; align-items: center; gap: 12px; diff --git a/public/header.html b/public/header.html index 550b67d..4294ae1 100644 --- a/public/header.html +++ b/public/header.html @@ -119,18 +119,20 @@ {/foreach} {else} - -