Skip to content

Instantly share code, notes, and snippets.

@jakeauyeung
Created August 8, 2014 03:00
Show Gist options
  • Save jakeauyeung/c01f9f150703f0ca36ac to your computer and use it in GitHub Desktop.
Save jakeauyeung/c01f9f150703f0ca36ac to your computer and use it in GitHub Desktop.
回到顶点2方法
/*goto top*/
.gotop{
position: absolute;
right: -148px;
bottom: 30px;
color: #000;
width: 124px;
z-index: 999;
}
// 回到顶部 bottom
var hdFloat = $(".gotop");
$(window).scroll(function () { hdFloat.animate({ bottom: $(document).height() - $(window).height() - $(window).scrollTop() }, { queue: false, duration: 500 }) });
$('.goto').on('click', function(){
$('html,body').animate({
scrollTop: 0
}, 'slow');
return false;
});
// 回到顶部 top
var hdFloat = $(".gotop"),
hdFloatTops = hdFloat.offset().top;
$(window).scroll(function () { hdFloat.animate({ top: $(window).scrollTop() + hdFloatTops }, { queue: false, duration: 500 }) });
$('.goto').on('click', function(){
$('html,body').animate({
scrollTop: 0
}, 'slow');
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment