使用a标签的锚点链接调到最顶部,再使用scroll-behavior属性平滑属性;
第一步:
<a href="#id"></a>
<header id="header"></header>
<!-- 返回顶部按钮 -->
<a href="#header" class="to-top">
<i class="iconfont icon-next"></i>
</a>
第二步:在html根节点中设置
scroll-behavior:smooth;
html {
scroll-behavior: smooth;
}