我有一个固定的导航栏,所以当点击导航栏中的某个元素时我需要一点偏移量,为此我使用了这个代码(它对于导航栏元素非常好):
var offset = 68;
$('.navbar li a').click(function(event) {
event.preventDefault();
$($(this).attr('href'))[0].scrollIntoView();
scrollBy(0, -offset);
});
但我有两个按钮,它们也链接到网站的某些部分:
<div id="main">
<a href="denea.com"><img src="images/face.png" class="logo"></a>
<div id="promo">
<h2> So, your website doesn't look good anymore? <br><h3> We'll give it a second breath, then support you along the way.</h3></h2>
</div>
<div id="buttons">
<a href="#portfolio"><button id="portbut">
View portfolio
</button></a>
<a href="#contact"><button id="quotebut">
Get a quote
</button></a>
</div>
</div>
但是当我把他们的身份放在我上面提到的js代码中时,它不起作用,当&#34;移动&#34;时,不考虑偏移量。到网站的某个部分。
我应该编辑什么,以便对那些两个按钮考虑偏移量?
答案 0 :(得分:0)
如果有人需要,答案是:
$('#fullpage').fullpage({
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
scrollOverflow: true
});