From 9c199810529d2afeb7530600804dc481f922f78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E4=BA=BA=E7=94=B2?= Date: Sat, 3 Aug 2024 02:17:42 +0800 Subject: [PATCH] Update index.js --- static/script/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/script/index.js b/static/script/index.js index 97187d6..42b4238 100644 --- a/static/script/index.js +++ b/static/script/index.js @@ -1,8 +1,9 @@ // 头部滚动 (function(){ - let $header = document.querySelector('.header'); - document.addEventListener('scroll',function(){ - let scrollTop = document.documentElement.scrollTop; + let $header = document.querySelector('.mod-head'); + document.querySelector('.scroll-container').addEventListener('scroll',function(){ + let scrollTop = this.scrollTop; + console.log('[scrollTop]',scrollTop); let ratio = Math.min(scrollTop/1000,1); $header.style.background = 'rgba(255,255,255,'+(ratio*0.8)+')'; $header.style.boxShadow = '1px 1px 6px rgba(0,0,0,'+(ratio*0.1)+')';