html smoothscroll

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html smoothscroll相关的知识,希望对你有一定的参考价值。

// you can change the offset by changing "-120" to a different number 

// smooth scroll
$(document).ready(function(){
	$('a[href^="#"]').on('click',function (e) {
	    e.preventDefault();

	    var target = this.hash;
	    var $target = $(target);

	    $('html, body').stop().animate({
	        'scrollTop': $target.offset().top-120
	    }, 900, 'swing', function () {
	        window.location.hash = target;
	    });
	});
});
// important a-tags should start with a #
// and divs or sections should have a id with the name

<nav>
	<a href="#home">Home</a>
	<a href="#work">Work</a>
	<a href="#video">Video</a>
	<a href="#testimonials">testimonials</a>
</nav>

以上是关于html smoothscroll的主要内容,如果未能解决你的问题,请参考以下文章

UITableView(_UITableViewPrivate) _smoothscroll: 负责啥?

jQuery 插件 smoothscroll

jQuery 插件 smoothscroll

javascript SmoothScroll

javascript smoothscroll

javascript jQuery_SmoothScroll