纯js实现页面返回顶部的动画
2021-06-07 10:03
标签:tran blog into int one ase ... style span 啥也不说了,直接上代码 需要的请随意拿走.... 纯js实现页面返回顶部的动画 标签:tran blog into int one ase ... style span 原文地址:http://www.cnblogs.com/JosephBee/p/7326556.html1 var scrollTop = document.body.scrollTop;
2 document.body.style.marginTop = -scrollTop + ‘px‘;
3 document.body.scrollTop = 0;
4 document.body.style.transition = ‘all 1s ease-in-out‘;
5 document.body.style.marginTop = 0;
6 setTimeout(function () { document.body.style.transition = ‘none‘; }, 1000);