Created
April 5, 2013 15:55
-
-
Save creamidea/5320431 to your computer and use it in GitHub Desktop.
使用jquery完成平滑的滚动效果
This file contains hidden or 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
//需要jquery, 当然你也可以全部纯手工打造 | |
$('#text-table-of-contents').delegate('a', 'click', function() { | |
var target = $(this).attr("href"); | |
var scrollNum = $(target)[0].offsetTop; | |
$('html, body').animate({ scrollTop: scrollNum-24 }, 'slow'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment