From a49759949d216cfcbe428b21e0ebdc33ed71efa5 Mon Sep 17 00:00:00 2001 From: yiqiu Date: Wed, 18 Mar 2026 19:56:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=BC=E8=88=AA=E6=A0=8F=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E5=8D=8A=E9=80=8F=E6=98=8E=E6=AF=9B=E7=8E=BB?= =?UTF-8?q?=E7=92=83=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 顶部时完全透明 - 滚动 >10px 后渐变为半透明毛玻璃 (0.75 透明度 + blur) - CSS transition 平滑过渡 --- common/common.css | 18 +++++++++++++----- common/common.js | 10 ++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/common/common.css b/common/common.css index b6495bd..f989224 100644 --- a/common/common.css +++ b/common/common.css @@ -76,11 +76,19 @@ body { left: 0; width: 100%; z-index: 9999; - /* 深色毛玻璃 Header,与下拉菜单统一风格 */ - background: rgba(10, 12, 22, 0.92); - backdrop-filter: blur(16px); - -webkit-backdrop-filter: blur(16px); - box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06); + background: transparent; + backdrop-filter: none; + -webkit-backdrop-filter: none; + box-shadow: none; + transition: background 0.3s ease, backdrop-filter 0.3s ease, box-shadow 0.3s ease; +} + +/* 滚动后变半透明毛玻璃 */ +.nav-shadow.scrolled { + background: rgba(10, 12, 22, 0.75); + backdrop-filter: blur(20px); + -webkit-backdrop-filter: blur(20px); + box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04); } .nav-header { diff --git a/common/common.js b/common/common.js index 140b743..af8729c 100644 --- a/common/common.js +++ b/common/common.js @@ -126,6 +126,16 @@ $(function () { location.href = url; }; function initHeader() { + // 滚动时导航栏变半透明毛玻璃 + var navShadow = document.querySelector('.nav-shadow'); + window.addEventListener('scroll', function () { + if (window.scrollY > 10) { + navShadow.classList.add('scrolled'); + } else { + navShadow.classList.remove('scrolled'); + } + }); + let showIndex = 0; let hoverTimer = null; let leaveTimer = null;