Mc *_*aya 3 html javascript css twitter-bootstrap
这是我的页脚代码。
<div class="row">
<div class="col-md-12">
<div> the part that always showing at the bottom </div>
</div>
<div class="col-md-12">
<div> show only if the user reaching the bottom of the page </div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是我希望我的页脚粘在页面底部,直到用户到达底部,然后显示其他内容。
这里需要一点Javascript。下面的代码应该可以工作。
$(document).ready(function() {
$('#footer-final').hide()
});
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$('#footer-inter').hide()
$('#footer-final').show()
}
});
Run Code Online (Sandbox Code Playgroud)
我假设您已经拥有使页脚粘在页面底部 ( position:fixed; bottom=0;)的 CSS,在这种情况下,您可以替换任何代码来隐藏中间页脚并在用户滚动时显示您想要显示的任何其他内容至底部。
仅在 CSS 的帮助下,您就可以将其重新考虑为两个页脚,一个弹出,另一个无聊 ;)
[id^=foo]{
background:orange;
padding:5px;
font-size:25px;
}
#foo-boring{
position:fixed;
bottom:0;
right:0;
left:0;
}
#foo-pop{
position:absolute;
height:70px;
right:0; left:0;
}Run Code Online (Sandbox Code Playgroud)
<div>SCROLL ME DOWN<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br>much contents there.<br> END.</div>
<div id="foo-pop"><b>POP!1!!!1!!1!11!</b></div>
<div id="foo-boring">The boring footer.</div>Run Code Online (Sandbox Code Playgroud)