Update index.js
This commit is contained in:
parent
c66541124a
commit
9c19981052
@ -1,8 +1,9 @@
|
|||||||
// 头部滚动
|
// 头部滚动
|
||||||
(function(){
|
(function(){
|
||||||
let $header = document.querySelector('.header');
|
let $header = document.querySelector('.mod-head');
|
||||||
document.addEventListener('scroll',function(){
|
document.querySelector('.scroll-container').addEventListener('scroll',function(){
|
||||||
let scrollTop = document.documentElement.scrollTop;
|
let scrollTop = this.scrollTop;
|
||||||
|
console.log('[scrollTop]',scrollTop);
|
||||||
let ratio = Math.min(scrollTop/1000,1);
|
let ratio = Math.min(scrollTop/1000,1);
|
||||||
$header.style.background = 'rgba(255,255,255,'+(ratio*0.8)+')';
|
$header.style.background = 'rgba(255,255,255,'+(ratio*0.8)+')';
|
||||||
$header.style.boxShadow = '1px 1px 6px rgba(0,0,0,'+(ratio*0.1)+')';
|
$header.style.boxShadow = '1px 1px 6px rgba(0,0,0,'+(ratio*0.1)+')';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user