【问题标题】:Fullpage.js wont scroll up after clicking on link href单击链接href后,Fullpage.js不会向上滚动
【发布时间】:2022-08-18 18:47:28
【问题描述】:

我正在使用最新版本的 fullpage.js(4.0.10)。

我无法成功将其放在 jsfidle 许可证上错误阻止我使用 CDN 所以我在这里放了一段非常简单的代码,在本地复制过去会重现问题(当然链接回 fullpage.js 和 fullpage.css)。

所以一切正常,直到我单击“按钮>a href=here”转到幻灯片#here

然后我根本无法向上滚动我必须一直向下滚动并向下滚动一次才能向上滚动到幻灯片 id \"#here\" 的上方

我希望能够在触发指向 id 元素的链接后向上滚动。

<button type=\"button\"><a href=\"#here\">here</a></button>
<h1>fullPage.js</h1></div>
  <div class=\"section\" id=\"section1\">
    <div class=\"slide\" id=\"here\"><h1>Simple Demo</h1></div>
    <div class=\"slide\"><h1>Only text</h1></div>
    <div class=\"slide\"><h1>And text</h1></div>
    <div class=\"slide\"><h1>And more text</h1></div>
  </div>
  <div class=\"section\" id=\"section2\">
    <h1>No wraps, no extra markup</h1>
  </div>
  <div class=\"section\" id=\"section3\">
    <h1>Just the simplest demo ever</h1>
  </div>
</div>

code to run locally

    标签: fullpage.js


    【解决方案1】:

    该问题已回答here

    我粘贴:

    您可以使用anchors 选项为每个部分分配不同的锚点:

    new fullpage('#fullpage', {
        anchors: ['one', 'two', 'here', 'four'],
        
            //your other options...
    });
    

    这样#here 锚将链接到第三部分。 https://jsfiddle.net/g26adykw/

    另一种选择只是使用 fullPage.js JS 方法,例如 moveTo

    【讨论】:

      猜你喜欢
      • 2021-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      • 1970-01-01
      相关资源
      最近更新 更多