如何在通过 CSS 滚动到达底部时隐藏 DIV?

Has*_*ain 3 html javascript css

这是我的 div style

<style>
#N_fixedBottom
{
   position:fixed;
   bottom:0px;
   left:0px;
   right:0px;
   background-color:#004369;
   width:100%;
   height:20px;
   z-index:100;
}

</style>
<div id="N_fixedBottom">

</div>
Run Code Online (Sandbox Code Playgroud)

div当它向下滚动到页面的底部应该隐藏。因为这个 DIV 隐藏了我的页脚。

Moo*_* GK 5

假设 body 的margin值为 0。否则,您需要将顶部和底部边距添加到$('body').height().

$(document).ready(function(){
   $(window).scroll(function() {
       if ($('body').height() <= ($(window).height() + $(window).scrollTop())) {
           $('#N_fixedBottom').hide();
       }
    });
});
Run Code Online (Sandbox Code Playgroud)