jspul设置滚动条_javaScript实现滚动条事件详解本⽂实例为⼤家分享了js实现滚动条事件的具体代码,供⼤家参考,具体内容如下
代码:
body {
margin: 0;
padding: 0;
}
.cont {
height: 7000px;
}
#top {
position: fixed;
width: 100%;
height: 55px;
jsp帮助文档
top: 0px;
left: 0px;
background-color: rosybrown;
display: none;
}
#left {
position: fixed;
width: 50px;
height: 400px;
top: 150px;
left: 50px;
background-color: cadetblue;
display: none;
}
#left ul {
list-style: none;
padding-left: 0px;
}
#left ul li {
border: 1px solid white;
/*color: azure;*/
height: 30px;
line-height: 30px;
text-align: center;
margin: 15px auto;
/*display: none;*/
}
.a {
background-color: burlywood;
color: #FFFFFF;
}
//滚动事件
function myScroll() {
var i = document.body.scrollTop;
var top = ElementById("top"); var left = ElementById("left"); var f1 = ElementById("f1"); var f2 = ElementById("f2"); var f3 = ElementById("f3"); var f4 = ElementById("f4");
var f5 = ElementById("f5"); var f6 = ElementById("f6"); //控制顶部
if(i >= 1000) {
top.style.display = "block";
top.innerHTML = i;
} else {
top.style.display = "none";
}
//控制左侧
if(i >= 2000) {
left.style.display = "block";
} else {
left.style.display = "none";
}
//显⽰楼层
if(i >= 2000 && i <= 2500) {
f1.className = "a";
f2.className = "";
f3.className = "";
f4.className = "";
f5.className = "";
f6.className = "";
} else if(i > 2500 && i <= 3000) {
f1.className = "";
f2.className = "a";
f3.className = "";
f4.className = "";
f5.className = "";
f6.className = "";
} else if(i > 3000 && i <= 3500) {
f1.className = "";
f2.className = "";
f3.className = "a";
f4.className = "";
f5.className = "";
f6.className = "";
} else if(i > 3500 && i <= 4000) {
f1.className = "";
f2.className = "";
f3.className = "";
f4.className = "a";
f5.className = "";
f6.className = "";
} else if(i > 4000 && i <= 4500) {
f1.className = "";
f2.className = "";
f3.className = "";
f4.className = "";
f5.className = "a";
f6.className = "";
} else if(i > 4500 && i <= 5000) {
f1.className = "";
f2.className = "";
f3.className = "";
f4.className = "";
f5.className = "";
f6.className = "a";
}
}
1F
2F
3F
4F
5F
6F
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持脚本之家。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。