I'm using smoothscroll.js to navigate my site. It stops on the correct anchor in Firefox, however in Chrome it passes the point on the first click of the link, and pushes the content to the top, hiding the content behind the page. then if you click it again, it aligns correctly. I've seen the problems on other sites as well. Curious to see if others have the same problem. Chrome seems to ignore any top padding or margin or positioning (example: top:20%;).
Scroll to anchor with fixed header, content hidden behind header, margin and top padding not working
Asked
Active
Viewed 1.6k times
4 Answers
10
SOLVED: http://nicolasgallagher.com/jump-links-and-viewport-positioning/demo/#method-D
There are several methods available.

Commandrea
- 561
- 3
- 10
- 24
-
I'm having trouble understanding how the #target in these methods correlates to the . I was trying - like in the demo- but no go. Any tips? – ATSiem Oct 02 '12 at 03:46
-
1Nicolas Gallagher's methods are a bit complicated in comparison with http://stackoverflow.com/a/13184714/109618 which just involves this HTML and this CSS: a.anchor{display: block; position: relative; top: -50px; visibility: hidden;} – David J. Sep 20 '14 at 23:48
-
i also think, after i tried several methods, that the hidden is a very easy and nice solution. it gives you good control over the position of the linked element without destroying your normal layout where you can use margin and padding as you want. thx David James – dichterDichter Jul 02 '15 at 07:25
0
I used Local Scroll (JQuery) to do this.
It allows you to do a top offset
$.localScroll({
offset: -100
});

optimiertes
- 4,002
- 1
- 22
- 15
0
I find this solution very easy and useful. You just need to add 1 line of CSS.
html {
scroll-padding-top: 70px; /* height of sticky header, because the header hides the content when jumping to it */
}
original answer: https://stackoverflow.com/a/56467997
-2
This may be due to a new wordpress theme using the header html5 element. I changed my header to a div, and it worked fine.

Ash Andrien
- 11