滚动换色

来源:互联网 发布:steam数据统计 编辑:程序博客网 时间:2024/04/24 02:58

<!DOCTYPE html>

<html>

<head>

<metacharset="UTF-8">

<title>滚动换色</title>

<styletype="text/css">

body{

height:5000px;

transition:all1s linear 0s;

}

</style>

</head>

<body>

<scripttype="text/javascript">

varb = document.body;

b.onscroll= function(){

console.log(b.scrollTop)

if(b.scrollTop>= 300 && b.scrollTop <= 1000){

b.style.background= "red";

}

else if(b.scrollTop> 1000 && b.scrollTop <= 3000){

b.style.background= "green";

}

else{

b.style.background= "blue";

}

}

</script>

</body>

</html>

0 0
原创粉丝点击