Could anyone explain why when scrolling on this site it jitters on certain pages?
I can see a few changes to the theme through a child theme, and allot of ‘!important’ being used.
But have no idea why the scrolls like that?
Could anyone explain why when scrolling on this site it jitters on certain pages?
I can see a few changes to the theme through a child theme, and allot of ‘!important’ being used.
But have no idea why the scrolls like that?
You must be logged in to post a comment.
The reason its jumping is because when the header is fixed (absolute) the next element ‘#main-content’ is being positioned at the top of the page, removing the need for scroll bars.
When you’re not scrolled below the top of the header it removes the ‘fixed-header’ class which resets it back to the way it was originally – hence the jump.
The fix using CSS:
I’m pretty sure you could do this all in CSS though if you just added the .fixed-header class from the start making it position: absolute; top: 0; and removed the javascript.
I believe that your problems centre around this bit of JavaScript in non-mobile.js;
First of all, your opening line of jQuery isn’t necessary. It should be just;
That will fire the jQuery on document load and let you use $ without conflict.
The next most obvious thing is this;
You should probably either add the class and then style with normal CSS OR add inline CSS rather than do both.
It’s hard to see what you’re trying to achieve with the header, so I can’t really suggest alternative code at the mo, but it looks like you just need the header to remain fixed to the top of the page?
If so you can do that without JavaScript, and with;
And then just add a bit of padding to bump your content down.