// 基于Jq的锚点平滑过渡
$('a[href*=#],area[href*=#]').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetOffset = $target.offset().top - 50;
$('html,body').animate({
scrollTop: targetOffset
},
1000);
return false;
}
}
});
html锚点平滑滚动
最新推荐文章于 2023-07-22 20:44:41 发布