[英]Change CSS class after scrolling 100% screen height down
I'm making a single page website and i want to show nav-menu on second part till end. 我正在制作一个单页网站,并且我想在第二部分中显示导航菜单,直到结束。 I found this question: Change CSS class after scrolling 1000px down 我发现了这个问题: 向下滚动1000px后更改CSS类
...and i used the answer of AlienWebguy ...而且我使用了AlienWebguy的答案
$(document).scroll(function() {
$('#menu').toggle($(this).scrollTop()>1000)
});
But i don't want to do 1000px. 但我不想做1000px。 I want to use it 100% of screen that it can change with different platforms or resolution. 我想使用它可以在不同平台或分辨率下更改的屏幕的100%。
Do you know what can i do? 你知道我能做什么吗?
Use this: 用这个:
$(document).scroll(function() {
var windowHeight = $(window).height();
$('#menu').toggle($(this).scrollTop()>windowHeight)
});
You can replace 1000
with $(window).height()
您可以将$(window).height()
替换为1000
As in: 如:
$(document).scroll(function() {
$('#menu').toggle($(this).scrollTop()>$(window).height())
});
You can use that : 您可以使用:
$(document).on("scroll", function(){
if($(document).scrollTop() >= ($(document).height() - $(window).height())){
//here, you're at the bottom of the page
console.log("BOTTOM");
} else {
//here, you're not arrived yet
}
});
it will work for every screen size, in theory. 从理论上讲,它将适用于每种屏幕尺寸。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.