![](/img/trans.png)
[英]How to determine if the bottom of a website was reached on iPhone browser?
[英]How to determine if after scrolling the bottom of browser window has reached top of DIV?
我正在尝试使用jQuery / Javascript解决此问题:
当浏览器向下滚动并且窗口底部到达页脚DIV的顶部时,请更改CSS代码。
问题示例: https : //elodywedding.com/blog (确保您的浏览器窗口为移动设备尺寸。)
如果向下滚动到较小分辨率的页脚,则页脚会静态浮动,并位于“标签” DIV上方。 我需要将位置重新设置为绝对。
有什么想法如何检测滚动何时导致窗口到达页脚DIV的顶部?
像这样的东西似乎起作用: https : //jsfiddle.net/zk49cuy7/
<style type="text/css">
#body {
height:1500px;
background-color:red;
}
#footer {
height:200px;
background-color:blue;
}
</style>
<div id="body"></div>
<div id="footer"></div>
jQuery(function($){
$(window).bind('scroll', function(e){
if($(window).scrollTop() + window.innerHeight >= $('#footer').offset().top)
{
console.log('BOTTOM');
}
else
{
console.log('NOT BOTTOM');
}
});
});
绑定到窗口滚动并检查滚动顶部+窗口高度是否大于页脚的偏移顶部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.