Wordpress 向下滚动箭头到页面的一部分

Posted

技术标签:

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

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

谢谢

【问题讨论】:

【参考方案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;
    
  
);
);

【讨论】:

以上是关于Wordpress 向下滚动箭头到页面的一部分的主要内容,如果未能解决你的问题,请参考以下文章