15

I am using the jQuery scrollTo plugin as you can see on the page which I'm building http://portfolio.tomvervoort.net/

Because of the 300px fixed header the content moves under the header. You can see this clearly when you click the about button in the menu. Is it possible to add an 300px offset to the scrollTo script so everything stays positioned under the header/menu?

1
  • Can we have the code in the question please so the abbreviated answer below makes sense! Commented Sep 17, 2019 at 15:18

2 Answers 2

21

You could try changing this line in jquery.nav.js:

$.scrollTo(newLoc, o.scrollSpeed, {

to

$.scrollTo($('newLoc').offset().top-300, o.scrollSpeed, { 

So instead of telling scrollto to scroll to exactly that element, you get the position of the element yourself and subtract 300

Sign up to request clarification or add additional context in comments.

3 Comments

Awesome, Worked like a charm!
Makes no sense without context
@ChrisPink i think it's not too hard to figure out the context from the answer even if the website from the question isn't online any more
21

You can use the "offset" setting as described on:

http://flesler.blogspot.com.ar/2007/10/jqueryscrollto.html

Something like:

$.scrollTo(newLoc, o.scrollSpeed, {
     // ...
     offset:-300
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.