Skip to content

Instantly share code, notes, and snippets.

@anythinggraphic
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anythinggraphic/5908edb1f415cc829822 to your computer and use it in GitHub Desktop.
Save anythinggraphic/5908edb1f415cc829822 to your computer and use it in GitHub Desktop.
Sticky Navigation and Scrolling
<!-- http://anythinggraphic.net/sticky-navigation-and-animated-scrolling/ -->
<div class="sticky">
<ul class="sticky-navigation">
<a href="#section_1">Your Title or Text Here</a>
<a href="#section_2">Your Title or Text Here</a>
<a href="#section_3">Your Title or Text Here</a>
</ul>
</div>
<div id="section_1">
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p>
</div>
<div id="section_2">
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p>
</div>
<div id="section_3">
<p>Completely synergize resource sucking relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p>
</div>
// http://anythinggraphic.net/sticky-navigation-and-animated-scrolling/
$(function(){ // document ready
var stickyTop = $('.sticky').offset().top; // returns number
$(window).scroll(function(){ // scroll event
var windowTop = $(window).scrollTop(); // returns number
if (stickyTop < windowTop) {
$('.sticky').css({ position: 'fixed', top: 0 });
} else {
$('.sticky').css('position','static');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment