【发布时间】:2018-05-14 10:37:00
【问题描述】:
有谁知道如何在 wordpress 中放置一个向下滚动到页面另一部分的箭头。该箭头将位于首页标题处,一旦用户看到它,他们就会单击它以向下滚动到页面的下一部分。
谢谢
【问题讨论】:
有谁知道如何在 wordpress 中放置一个向下滚动到页面另一部分的箭头。该箭头将位于首页标题处,一旦用户看到它,他们就会单击它以向下滚动到页面的下一部分。
谢谢
【问题讨论】:
它被称为“锚”。
链接:
<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" 属性的标签。
【讨论】:
标题中的箭头应该是链接:
<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;
}
}
});
});
【讨论】: