我在HTML中尝试了几乎所有东西,一旦我们向下滚动就隐藏了页脚,但它失败了。我尝试使用的代码是:
.wrap {
position: relative;
text-align: center;
margin: 0 auto;
/*replace 900px with your width*/
width: 900px;
}
#footer {
width: 100%;
float: left;
}
#footer {
position: absolute;
width: 100;
bottom: 0;
color: white;
z-index: 999999;
}

<div id="footer">
<div class="wrap">
<p>This would be your footer content!</p>
</div>
</div>
&#13;
答案 0 :(得分:0)
为此您需要使用scrollTop()功能,如下例所示:
$(window).scroll(function(){
var sroll_val = $(this).scrollTop();
if(sroll_val > 50 && sroll_val < 70){
$('.wrap').animate({opacity:0});
}if(sroll_val > 70 && sroll_val < 90){
$('.wrap').animate({opacity:1});
}
})
&#13;
body{
}
.wrap {
text-align: center;
margin: 0 auto;
width: 90%;
opacity:1;
}
#footer {
width:100%;
}
#footer {
position:fixed;
width:100;
color: white;
bottom:0;
background-color:pink;
z-index:999999;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='main'>
<p>content</p><p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<div id="footer">
<div class="wrap">
<p>This would be your footer content!</p>
</div>
</div>
</div>
&#13;