Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <body style="height:500px">
    <div class="header--fixed" style="position:fixed; background-color:#cccccc;">
      <div class="container">
        <div class="navbar-brand" style="width:100px; height:50px; background-color:#234567;">


                .container {
margin:0 auto 0 auto;

.header--fixed {
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 10;


                var logo = {};
jQuery(document).ready(function($) {
	logo.width_default = 100;	//i.e size defined in template params
	logo.height_default = 50;	//i.e size defined in template params
	logo.scale_factor =	2;	//value to scale up the logo befor reducing on scroll
	logo.ratio = logo.height_default / logo.width_default;
	logo.height_max = logo.height_default*logo.scale_factor;
	var main_width = $('.container').width();
	var logo_width = $('.navbar-brand').width();
	logo.margin_max = (main_width/2)-(logo_width/2);
  $(window).scroll(function() {
		var toppos = 10;	//top margin
		var logo_margin = 10; //left margin
		var main_width = $('.container').width(); //width of container div
		var logo_width = $('.navbar-brand').width(); //current width of logo
		var logo_center_margin = (main_width/2)-(logo_width/2); //left margin to center image = main width/2-logo width/2
		var logo_travel = logo_center_margin - logo_margin; //total travel = center margin - left margin
		var bottompos = logo.height_max - logo.height_default + toppos; //y position of big logo bottom
		var scale_factor = logo_travel / (logo.height_max - logo.height_default);
  		if ($(window).scrollTop() >= toppos && $(window).scrollTop() <= bottompos) {
			var logo_margin = parseInt($('.navbar-brand').css('margin-left'));
			var new_height = logo.height_max - ($(window).scrollTop()-toppos);
			$('.navbar-brand').css('height', new_height);
			$('.navbar-brand').css('width', new_height/logo.ratio);
			$('.navbar-brand').css('margin-left', (bottompos-$(window).scrollTop())*scale_factor);
			console.log ($(window).scrollTop() + " " + scale_factor +" "+ $(window).scrollTop()*scale_factor);
  		if ($(window).scrollTop() <= toppos) {
  		if ($(window).scrollTop() >= bottompos) {
			$('.navbar-brand').css('height', logo.height_default);
			$('.navbar-brand').css('width', logo.width_default);
			$('.navbar-brand').css('margin-left', logo_margin);