Skip to content

Instantly share code, notes, and snippets.

@NickDeckerDevs
Created December 7, 2018 03:38
Show Gist options
  • Select an option

  • Save NickDeckerDevs/31c78fcd7132f8e2a5a932fbc7b48f46 to your computer and use it in GitHub Desktop.

Select an option

Save NickDeckerDevs/31c78fcd7132f8e2a5a932fbc7b48f46 to your computer and use it in GitHub Desktop.
Scroll to the bottom of the hero div after clicking on an item [STICKY header]
// <header>
// <div class="logo">......</div>
// </header>
//
// <div id="hero">
// <span class="scroll-to-bottom-of-hero">Click here to scroll to bottom of hero</span>
// </div>
// #hero is the ID of the hero element
// header is the header element that is sticky
$('.find-out-how-link').on('click', function() {
var heroHeight = $('#hero').outerHeight();
var navHeight = $('header').outerHeight();
$('html, body').animate({
scrollTop: (heroHeight - navHeight) + 'px'
}, 'slow');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment