【问题标题】:Wordpress scroll down arrow to a section of pageWordpress 向下滚动箭头到页面的一部分
【发布时间】:2018-05-14 10:37:00
【问题描述】:

有谁知道如何在 wordpress 中放置一个向下滚动到页面另一部分的箭头。该箭头将位于首页标题处,一旦用户看到它,他们就会单击它以向下滚动到页面的下一部分。

谢谢

【问题讨论】:

    标签: jquery wordpress plugins


    【解决方案1】:

    它被称为“锚”。

    链接:

    <a href="#section_at_footer">Go to footer</a>
    

    部分应包含

    <div id="section_at_footer" name="section_at_footer"></div>
    

    <span id="section_at_footer" name="section_at_footer"></span>
    

    或任何具有此 name="section_at_footer" 属性的标签。

    【讨论】:

    • 只需在此处添加:此解决方案会跳转到目标 - 如果您想要滚动,有很多方法可以做到,例如 javascript 或插件。
    【解决方案2】:

    标题中的箭头应该是链接:

    <a href="#NEXT_SECTION">Read more</a>
    

    部分应包含:

    <section id="NEXT_SECTION"></section>
    

    为了平滑滚动,它需要 javascript,

    $(document).ready(function(){
    $('a[href*="#"]:not([href="#"])').click(function() {
      if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
        if (target.length) {
          $('html, body').animate({
            scrollTop: target.offset().top
          }, 500);
          return false;
        }
      }
    });
    });
    

    【讨论】:

      猜你喜欢
      • 2017-09-15
      • 1970-01-01
      • 2015-02-08
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 1970-01-01
      • 1970-01-01
      • 2020-11-20
      相关资源
      最近更新 更多