css3如何实现click后页面过渡滚动到顶部

var getTop = document.getElementById("get-top");
var head = document.getElementById("head");
getTop.onclick = function () {
    var time = setInterval(function () {
        document.body.scrollTop = document.body.scrollTop - 50;
        if (document.body.scrollTop === 0) {
            clearInterval(time);
        }
    }, 1);

};

链接:https://segmentfault.com/q/1010000003855799
posted @ 2016-11-02 18:28  成忠  阅读(2360)  评论(0编辑  收藏  举报