I'm working on a site that has a navbar and a menu (the height of the two adds 101px) , which scrolls to them, they pin at the top of the screen and float. p>
I want the anchors I set on the page not to be overridden by the menu when clicked by the user on the menu buttons.
For example, when the user clicks on "Top Dates" the anchor takes you to the desired location, but as the menu floats it overrides the title. You can solve this by changing the position of the page, but this also changes the height of the page.
I saw some resolution templates using JQuery, but all of those I tested did not work.
My site: link
What I want to do is like this example: link
I'm using this code:
<script src="http://code.jquery.com/jquery-1.7.1.js"></script><scripttype="text/javascript">
$('a[href*=#]').bind("click", function(e) {
var target = $(this).attr("href"); //Get the target
var scrollToPosition = $(target).offset().top - 101;
$('html,body').animate({ 'scrollTop': scrollToPosition }, 600, function(target){
window.location.hash = target;
});
e.preventDefault();
});
</script>
Oh, and the menu links are not simply defined as "#link", they are complete link , because the user is on another page it will be redirected to the correct page and the anchor will take you to the defined position.