首页 > 其他 > 详细

锚点跳转的过渡效果

时间:2016-03-24 12:59:11      阅读:241      评论:0      收藏:0      [点我收藏+]

 

CSS实现:http://stackoverflow.com/questions/17631417/css-pure-css-scroll-animation

jq实现:

$(function () {
    $(‘a[href*=#],area[href*=#]‘).click(function () {
        console.log(this.pathname)
        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;
                $(‘html,body‘).animate({
                    scrollTop: targetOffset
                },
                        1000);
                return false;
            }
        }
    });
});

  

锚点跳转的过渡效果

原文:http://www.cnblogs.com/dunitian/p/5314749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!