锚点-滚动

a 标签

a.html里:
<a href="b.html#abc">xxx</a>

b.html里加一个锚记:
<a name="abc"></a>

// css 
html {
    scroll-behavior: smooth;
  }

js 实现

   document.getElementById('ID').scrollIntoView({
                    behavior: 'smooth', // 平滑过渡
                    block: 'start' // 上边框与视窗顶部平齐
                });
posted @ 2023-02-02 10:58  过好每一天2022  阅读(14)  评论(0)    收藏  举报