123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id="navigation"><p>Hidden navigation for users that have trenched deep into your page!</p></div>
	<div id="percentageCounter"><h1>0%</h1></div>
<div class="container">
  <a href="https://github.com/ellenbrook/jQuery-scroll-distance-detection/" target="blank">This script has been updated. View the new (easy to use version) on Github!</a>
</div>
	<div class="content">
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vitae magna ut nulla lobortis iaculis. Maecenas eleifend nibh vehicula dolor interdum auctor. Nullam ut mi a dolor luctus pulvinar in quis nunc. Mauris molestie eget odio eget porttitor. Etiam suscipit ante sapien, non iaculis lacus vulputate non. Nulla vulputate lectus vel leo pulvinar, lobortis rutrum felis porta. Cras egestas, odio ac venenatis tincidunt, dui erat congue ligula, at congue nulla urna ac tortor. Ut in dolor varius, malesuada erat in, semper nisl. Cras euismod arcu sem, ac consectetur sapien rutrum quis. Vestibulum sed feugiat nulla. Duis lacinia ac mauris dictum pellentesque. Vestibulum ut dictum sem. Sed volutpat ornare nisi, vitae faucibus diam auctor id. Nam et euismod lectus.</p>
	<p>In porttitor, velit id varius volutpat, purus purus ornare urna, in cursus mauris nibh vitae nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec nibh neque, scelerisque a congue a, dictum eget mi. Donec iaculis mauris in porta eleifend. Nam eu nisi velit. Etiam a semper massa. Praesent consequat sapien facilisis tellus auctor, sit amet tincidunt augue faucibus. Aliquam adipiscing elit a congue malesuada. Sed justo urna, vehicula a velit sed, sollicitudin cursus nunc. In auctor sapien nunc, non aliquam nisi euismod a. Maecenas ut est fringilla massa laoreet ullamcorper at eu mauris. Praesent quis porttitor justo.</p>
		<p>Cras mattis nibh nec justo tempor, id rhoncus magna sollicitudin. Cras iaculis dolor sit amet fermentum semper. Fusce eget pellentesque turpis. Cras placerat urna at lacus placerat, sit amet hendrerit magna aliquet. Vestibulum lobortis lectus et nibh imperdiet ornare. Sed quis purus hendrerit, sodales lectus quis, auctor sem. Donec felis sapien, tincidunt eget ullamcorper ac, scelerisque at ligula. Curabitur cursus placerat vulputate. Maecenas laoreet est nunc, sit amet eleifend libero suscipit in. Duis nunc urna, porttitor a elit at, iaculis tincidunt elit. Sed quis consectetur mauris. Nam ut semper dui.</p>
			<p>Pellentesque porttitor tortor nec tortor ullamcorper, nec scelerisque mi condimentum. Morbi cursus molestie euismod. Sed ullamcorper massa rutrum arcu auctor, eu posuere nunc interdum. Mauris ac est tellus. Nullam quis odio leo. Aenean consequat, felis in tristique iaculis, neque erat semper risus, eu commodo orci nisi quis sapien. Nullam quis elementum est. Vestibulum malesuada blandit turpis, ut imperdiet justo porttitor ac. Nullam in cursus magna. Donec ultricies ante eget massa convallis, a elementum orci tincidunt. Quisque id vulputate nunc. Pellentesque ut dictum turpis, non gravida libero.</p>
				<p>Proin molestie, urna non dapibus blandit, metus magna semper nisl, id tincidunt enim urna nec nulla. Quisque in magna et ante pharetra hendrerit placerat ac urna. Sed viverra turpis in sapien pellentesque, vel tincidunt sapien volutpat. Curabitur non nulla ac augue varius fringilla et sed augue. Phasellus quis consectetur urna. Donec molestie dui et tortor blandit, vel faucibus lacus consequat. Donec nulla diam, iaculis sed egestas ac, posuere vitae dui. Donec at cursus neque, non vestibulum enim. Aliquam augue nisi, eleifend sit amet dolor sit amet, consequat posuere orci. Cras nibh tellus, ornare at libero ac, consequat porta sapien. Aliquam ut mauris quis urna scelerisque luctus in ac enim. Nam nibh libero, mollis volutpat suscipit ac, viverra vel odio. Aliquam erat volutpat. Aenean adipiscing, nulla et ultrices commodo, lectus velit sagittis tellus, eget congue augue sapien at felis. Cras nec egestas sapien. Cras dapibus leo sed dolor laoreet, at ornare felis pretium.</p>
				<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vitae magna ut nulla lobortis iaculis. Maecenas eleifend nibh vehicula dolor interdum auctor. Nullam ut mi a dolor luctus pulvinar in quis nunc. Mauris molestie eget odio eget porttitor. Etiam suscipit ante sapien, non iaculis lacus vulputate non. Nulla vulputate lectus vel leo pulvinar, lobortis rutrum felis porta. Cras egestas, odio ac venenatis tincidunt, dui erat congue ligula, at congue nulla urna ac tortor. Ut in dolor varius, malesuada erat in, semper nisl. Cras euismod arcu sem, ac consectetur sapien rutrum quis. Vestibulum sed feugiat nulla. Duis lacinia ac mauris dictum pellentesque. Vestibulum ut dictum sem. Sed volutpat ornare nisi, vitae faucibus diam auctor id. Nam et euismod lectus.</p>
				<p>In porttitor, velit id varius volutpat, purus purus ornare urna, in cursus mauris nibh vitae nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec nibh neque, scelerisque a congue a, dictum eget mi. Donec iaculis mauris in porta eleifend. Nam eu nisi velit. Etiam a semper massa. Praesent consequat sapien facilisis tellus auctor, sit amet tincidunt augue faucibus. Aliquam adipiscing elit a congue malesuada. Sed justo urna, vehicula a velit sed, sollicitudin cursus nunc. In auctor sapien nunc, non aliquam nisi euismod a. Maecenas ut est fringilla massa laoreet ullamcorper at eu mauris. Praesent quis porttitor justo.</p>
				<p>Cras mattis nibh nec justo tempor, id rhoncus magna sollicitudin. Cras iaculis dolor sit amet fermentum semper. Fusce eget pellentesque turpis. Cras placerat urna at lacus placerat, sit amet hendrerit magna aliquet. Vestibulum lobortis lectus et nibh imperdiet ornare. Sed quis purus hendrerit, sodales lectus quis, auctor sem. Donec felis sapien, tincidunt eget ullamcorper ac, scelerisque at ligula. Curabitur cursus placerat vulputate. Maecenas laoreet est nunc, sit amet eleifend libero suscipit in. Duis nunc urna, porttitor a elit at, iaculis tincidunt elit. Sed quis consectetur mauris. Nam ut semper dui.</p>
				<p>Pellentesque porttitor tortor nec tortor ullamcorper, nec scelerisque mi condimentum. Morbi cursus molestie euismod. Sed ullamcorper massa rutrum arcu auctor, eu posuere nunc interdum. Mauris ac est tellus. Nullam quis odio leo. Aenean consequat, felis in tristique iaculis, neque erat semper risus, eu commodo orci nisi quis sapien. Nullam quis elementum est. Vestibulum malesuada blandit turpis, ut imperdiet justo porttitor ac. Nullam in cursus magna. Donec ultricies ante eget massa convallis, a elementum orci tincidunt. Quisque id vulputate nunc. Pellentesque ut dictum turpis, non gravida libero.</p>
				<p>Proin molestie, urna non dapibus blandit, metus magna semper nisl, id tincidunt enim urna nec nulla. Quisque in magna et ante pharetra hendrerit placerat ac urna. Sed viverra turpis in sapien pellentesque, vel tincidunt sapien volutpat. Curabitur non nulla ac augue varius fringilla et sed augue. Phasellus quis consectetur urna. Donec molestie dui et tortor blandit, vel faucibus lacus consequat. Donec nulla diam, iaculis sed egestas ac, posuere vitae dui. Donec at cursus neque, non vestibulum enim. Aliquam augue nisi, eleifend sit amet dolor sit amet, consequat posuere orci. Cras nibh tellus, ornare at libero ac, consequat porta sapien. Aliquam ut mauris quis urna scelerisque luctus in ac enim. Nam nibh libero, mollis volutpat suscipit ac, viverra vel odio. Aliquam erat volutpat. Aenean adipiscing, nulla et ultrices commodo, lectus velit sagittis tellus, eget congue augue sapien at felis. Cras nec egestas sapien. Cras dapibus leo sed dolor laoreet, at ornare felis pretium.</p>
	</div>
            
          
!
            
              $counter: true; //false to hide percentage


#navigation {
  position: fixed;
  top: -66px;
   left: 0; right: 0;
  width: 100%;
  height: 60px;
  background-color: #006699;
  box-shadow: 0px 3px 3px 0px rgba(21, 21, 21, 0.1);
/*		
#
#Edit these to change CSS transition delay, speed, and type 
#
*/
  transition: top .25s ease .5s;
}

#navigation p {
  text-align: center;
  color: #fff;
}

.container {
  text-align: center;
  margin-bottom: 2em;
}

#percentageCounter {
  @if $counter == true {
    position: fixed;
  } @else if $counter == false {
    display: none;
  }
	bottom: 10px;
	right: 10px;
}

h1 {
	font-size: +2em;
}

.content {
		width: 30%;
		margin: 0 auto;
		padding: 10px;
		border: 1px solid #000;
		background-color: #f5f5f5;
}
	
p {
	margin-bottom: 1em;
}
* { font-family: 'Open Sans', sans-serif; }
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300);
            
          
!
            
              	$(window).scroll(function(){
		
		// Change this to target a different percentage
		var targetPercentage = 70;
    
		//Change this to set the height of your nav bar so it hides properly. If you have a box shadow you may have to adjust this number to be height + shadow distance
		var navBarHeight = 66;
    
		//Change this to the ID of the content you are trying to show.
		var targetID = "#navigation";
		
		//Window Math
		var scrollTo = $(window).scrollTop(),
		docHeight = $(document).height(),
		windowHeight = $(window).height();
		scrollPercent = (scrollTo / (docHeight-windowHeight)) * 100;
		scrollPercent = scrollPercent.toFixed(1);
			
		$('#percentageCounter h1').text(scrollPercent+"%");

		if(scrollPercent > targetPercentage) {
			$(targetID).css({ top: '0' });
		}
		
		if(scrollPercent < targetPercentage) {
			$(targetID).css({ top: '-'+navBarHeight+'px' });
		}
								
	}).trigger('scroll');
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console