Created
August 8, 2014 03:00
-
-
Save jakeauyeung/c01f9f150703f0ca36ac to your computer and use it in GitHub Desktop.
回到顶点2方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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