[英]Detecting scroll to bottom pixel on back to top button
我有此解决方案的返回页首按钮。
HTML:
<div id='toTop'>To The Top!</div><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
CSS:
#toTop {
padding: 5px 3px;
background: #000;
color: #fff;
position: fixed;
bottom: 0;
right: 5px;
display: none;
}
JS:
$(window).scroll(function() {
if ($(this).scrollTop()) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
http://jsfiddle.net/robert/fjXSq/
工作正常 但我想滚动到底部200px时,得到滚动按钮给我。 如何设置此选项?
试试这个代码:
$(window).scroll(function() {
if ($(this).scrollTop() > ($('html').height() - $(window).height() - 200)) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.