JSFiddle - React, Tailwind, and code Playground

HTML

<div id="wrapper">
<header>
	<p id="logo"><a href="http://www.backslash.gr/" title="Backslash - Web development blog"><strong>Backslash</strong> - <span>Web development blog</span></a></p>
	<p id="back_to_article">Back to article: <a href="http://www.backslash.gr/content/blog/webdevelopment/6-navigation-menu-that-stays-on-top-with-jquery">A navigation menu that stays on top with jQuery</a></p>
</header>

<!-- START demo required html -->

<div id="demo_top_wrapper">

	<div id="demo_top">
		<div class="demo_container">
			<div id="my_logo">Our logo</div>
		</div>
	</div>

	<div id="sticky_navigation_wrapper">
		<div id="sticky_navigation">
			<div class="demo_container">
				<ul>
					<li><a href="#" class="selected">HOME</a></li>
					<li><a href="#">ABOUT US</a></li>
					<li><a href="#">SERVICES</a></li>
					<li><a href="#">CLIENTS</a></li>
					<li><a href="#">PARTNERS</a></li>
					<li><a href="#">CONTACT</a></li>
				</ul>
			</div>
		</div>
	</div>
	
</div><!-- #demo_top_wrapper -->

<!-- END demo required -->

<section id="main">

	<div id="content">
	
		<h1>A navigation menu that stays on top with jQuery</h1>
		<p>View source or <strong><a href="jquery-sticky-navigation.zip">download this demo</a></strong>.</p>
		
					<div style="width:728px; height:90px; margin:0 0 15px 0" class="">
			<script type="text/javascript"><!--
google_ad_client = "ca-pub-7245238297555978";
/* Backslash Leaderboard */
google_ad_slot = "5770639556";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>			</div>
			
	
		<p><strong>Scroll down to see this navigation menu sticking to the top of the page.</strong></p>
		
		<p>
		Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ultrices pellentesque facilisis. In semper tellus mollis nisl pulvinar vitae vulputate lorem consequat. Fusce odio tortor, pretium sit amet auctor ut, ultrices vel nibh. Lorem ipsum...

CSS

.demo_container { width:980px; margin:0 auto; }
#demo_top_wrapper { margin:0 0 20px 0; }
#demo_top { height:100px; padding:20px 0 0 0; }
#my_logo { font:70px Georgia, serif; }

#sticky_navigation_wrapper { width:100%; height:50px; }
#sticky_navigation { width:100%; height:50px; background:url(trans-black-60.png); -moz-box-shadow: 0 0 5px #999; -webkit-box-shadow: 0 0 5px #999; box-shadow: 0 0 5px #999; }
#sticky_navigation ul { list-style:none; margin:0; padding:5px; }
#sticky_navigation ul li { margin:0; padding:0; display:inline; }
#sticky_navigation ul li a { display:block; float:left; margin:0 0 0 5px; padding:0 20px; height:40px; line-height:40px; font-size:14px; font-family:Arial, serif; font-weight:bold; color:#ddd; background:#333; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; }
#sticky_navigation ul li a:hover, #sticky_navigation ul li a.selected { color:#fff; background:#111; }

JavaScript

$(function() {

	// grab the initial top offset of the navigation 
	var sticky_navigation_offset_top = $('#sticky_navigation').offset().top;
	
	// our function that decides weather the navigation bar should have "fixed" css position or not.
	var sticky_navigation = function(){
		var scroll_top = $(window).scrollTop(); // our current vertical position from the top
		
		// if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
		if (scroll_top > sticky_navigation_offset_top) { 
			$('#sticky_navigation').css({ 'position': 'fixed', 'top':0, 'left':0 });
		} else {
			$('#sticky_navigation').css({ 'position': 'relative' }); 
		}   
	};
	
	// run our function on load
	sticky_navigation();
	
	// and run it again every time you scroll
	$(window).scroll(function() {
		 sticky_navigation();
	});
	
	// NOT required:
	// for this demo disable all links that point to "#"
	$('a[href="#"]').click(function(event){ 
		event.preventDefault(); 
	});
	
});