【问题标题】:asp.net scroll to Anchor on button clickasp.net 在按钮单击时滚动到锚点
【发布时间】:2019-03-13 11:08:44
【问题描述】:

我有几个按钮可以滚动到页面顶部:

function topFunction() {
    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;
}

另一个滚动到某个锚点:

function Intro1Function() {
    document.getElementById('Intro1').scrollIntoView(true);
}

我也有像这样的标题后面的模糊背景:

   var pageContent = document.getElementById("mainContent"),
   pagecopy = pageContent.cloneNode(true),
   blurryContent = document.getElementById("blurryscroll");
   blurryContent.appendChild(pagecopy);
   window.onscroll = function () {
       blurryContent.scrollTop = window.pageYOffset;
   }

当我滚动到顶部时,我会平滑滚动内容和模糊内容。

但是,导航到锚点时,我无法滚动两者。只有模糊的内容会滚动,而不是主要内容。

我是asp.net布局编码的初学者,一点js知识都没有。

【问题讨论】:

    标签: javascript jquery html css scroll


    【解决方案1】:

    在 w3cschools 上有一个功能可以做到这一点,https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_eff_animate_smoothscroll

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      相关资源
      最近更新 更多