Created
June 10, 2014 18:50
-
-
Save awkale/f56302456ad8e2fb52e5 to your computer and use it in GitHub Desktop.
anchor scroll offset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// amount to offset | |
var offset = 80; | |
// offsets the anchor link by the desired amount from the top of the browser | |
$('.navbar li a').click(function(event) { | |
event.preventDefault(); | |
$($(this).attr('href'))[0].scrollIntoView(); | |
scrollBy(0, -offset); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment