我想要鏈接滾動到該部分。我不明白爲什麼這不起作用,鏈接要麼不工作,要麼不去滾動。我正在使用Scrollify插件。Scrollify鏈接
Javascript in the header。我應該把它放在頁腳中嗎?我讀的地方應該是在我以爲奇了頭......
$(function() {
$.scrollify({
section : ".section-class-name",
sectionName : "first",
easing: "easeOutExpo",
scrollSpeed: 1100,
offset : 0,
scrollbars: true,
standardScrollElements: "",
setHeights: true,
before:function() {},
after:function() {},
afterResize:function() {},
afterRender:function() {}
})
});
$(".first").click(function(e) {
e.preventDefault();
$.scrollify("move", $(this).attr("href"));
});
的HTML
<div class="section-class-name" data-name-section="first" style="background-color: red;">
<a href="#second" class="first">Second</a><br>
</div>
<div class="section-class-name" data-name-section="second" style="background-color: orange;"></div>
<div class="section-class-name" data-name-section="last" style="background-color: yellow;"></div>
不是真的working-我知道這個數據段名正在工作。如果URL在結尾處具有id/data部分名稱,那麼當我加載/刷新它時,窗口會自動滾動到該部分。但鏈接本身並不工作,除了將#部分名稱放在網址的末尾。 –