JQuery 实现锚点链接之间的平滑滚动
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JQuery 实现锚点链接之间的平滑滚动相关的知识,希望对你有一定的参考价值。
24. 解决链接锚点的生硬问题
$(‘.nav .btn[href*=#],.icon2,.icon3‘).click(function() { if (location.pathname.replace(/^\//, ‘‘) == this.pathname.replace(/^\//, ‘‘) && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $(‘[id=‘ + this.hash.slice(1) + ‘]‘); if ($target.length) { var targetOffset = $target.offset().top; $(‘html,body‘).animate({ scrollTop: targetOffset }, 1000); return false; } } })
以上是关于JQuery 实现锚点链接之间的平滑滚动的主要内容,如果未能解决你的问题,请参考以下文章