When scrolling on a website I've built, using the CSS property
position: fixed
top: 0;
bottom: 0;
This is a webkit issue that has yet to be resolved, oddly making the jump with JavaScript, rather than using the #
url value, doesn't cause the problem. To overcome the issue, I supplied a JavaScript version that takes the anchor value and finds the absolute position of the element with that ID and jump to that:
var elements = document.getElementsByTagName('a');
for(var i = 1; i < elements.length; i++) {
elements[i].onclick = function() {
var hash = this.hash.substr(1),
elementTop = document.getElementById(hash).offsetTop;
window.scrollTo(0, elementTop + 125);
window.location.hash = '';
return false;
}
}
I could refine this further and make it is that only it only looks for links beginning with a #
, rather than ever a
tag it finds.