앵커 URL '및 부드러운 스크롤로 내비게이션을 만들고 싶습니다. 하지만 그 페이지에서 저는 높이가 88px 인 끈적한 헤더를 사용합니다.부드러운 스크롤 앵커 jquery
product-anchor-links-action
클래스를 기반으로 부드러운 스크롤을 만드는 방법은 무엇입니까?
JSFiddle : https://jsfiddle.net/rx0txmek/2/
나의 현재 HTML :
<div class="product-page-nav">
<div class="container">
<ol class="product-anchor-links-list">
<li class="product-anchor-links-item"><a href="#productbeschrijving" class="product-anchor-links-action">Nav 1</a></li>
<li class="product-anchor-links-item"><a href="#specificaties" class="product-anchor-links-action">Nav 2</a></li>
<li class="product-anchor-links-item"><a href="#reviews" class="product-anchor-links-action">Nav 3</a></li>
</ol>
</div>
</div>
jQuery를 :
$(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
}, 1000);
return false;
}
}
});
});
에는 $ ('. stickyHeader')가 존재하지 않는 경우'reviews', 맞죠?! .... 정말하지 마십시오 질문은 jsFiddle에서 모두 필요하기 때문에 코드를 이해하기 위해 많은 노력을 기울이지 않은 것 같습니다. –
@ A.Wolff 답장을 보내 주셔서 감사합니다. 예, 나는 그것을 알고 있었지만, 나는 바이올린을 바꿨습니다. 그래서 그것은 완료되었습니다. 단 한 가지로는 나는 그것을 올바르게 할 수 없다/일하고있다. 부드러운 두루마리가 작동하지 않고 클래스를 기반으로합니다. –
jsFiddle이 예상대로 작동하므로 예상했던 것 대신 설명하십시오. '그것이 계급을 기반으로 한 것'당신은 무엇을 의미합니까? –