Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <header id="masthead" class="site-header">
    <hgroup>
        <h1 class="site-title"><a href="#" title="A very nice title" rel="home">A very nice title</a></h1>
        <h2 class="site-description">A very nice description.</h2>
    </hgroup>
    <nav id="site-navigation" class="main-navigation">
	<div class="menu-container">
            <ul id="menu-menu-1" class="nav-menu">
	        <li id="menu-item-1" class="menu-item menu-item-type-custom"><a href="#">Home</a></li>
	 	<li id="menu-item-2" class="menu-item menu-item-type-post_type"><a href="#">About</a></li>
	   </ul>
       </div>
    </nav>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla magna tellus, varius sit amet metus ut, feugiat posuere nibh. Aliquam sed tempus enim. Sed at porta lacus. Vivamus porttitor blandit dui, vitae pulvinar metus malesuada nec. Quisque condimentum mollis sem, a scelerisque enim placerat sit amet. Proin fermentum, libero a pulvinar viverra, sem sem ultrices odio, id tempus erat tortor in quam. Suspendisse a rhoncus nisl. Praesent ac tellus laoreet, dictum erat sit amet, auctor eros. Nunc placerat suscipit blandit. Ut in vestibulum dolor. Proin a tellus velit. Nam a porttitor lorem. Nulla sit amet dui vel neque dapibus euismod. Nam dictum elementum nisl vitae suscipit. In mi massa, pulvinar sagittis felis nec, euismod placerat ligula. Etiam blandit nibh et ligula posuere iaculis.</p>
              
            
!

CSS

              
                body {
  margin: 0;
  background-color: #456;
}

header {
  width:100%;
  float:left;
  top: -15px;
  background-color: #123;
  position: relative;
}

hgroup {
  width:90%;
  margin:0 auto;  
  background-color: #efefef;
}

p {
 height: 1800px;
  padding: 0 100px;
}

#menu-menu-1 {
  width:100%;
  border:0;
  list-style: none outside none;
  margin: 0;
  padding: 0;
}

#menu-menu-1 li {
  width:50%;
  display:inline-block;
  float: left;
  position: relative;
  list-decoration: none;
  margin: 0;
  padding: 0;
  text-align: center;
  background-color: #ddd;
  line-height: 40px;
}

.menu-container {
  height: 40px;
  width: 100%;
}

.fixed {
  position:fixed;
  top:0;
}
              
            
!

JS

              
                var num = $('#menu-menu-1').offset().top;
//number of pixels before modifying styles

$(window).bind('scroll', function () {
  var st = $(this).scrollTop();
  $('hgroup').css({ 'opacity' : (1 - st/(num)) });
  
    if ($(window).scrollTop() > num) {        
        $('#menu-menu-1').addClass('fixed');
        $('#menu-menu-1').css({ 'opacity' : (0.8) });
    } else {        
        $('#menu-menu-1').removeClass('fixed');
        $('#menu-menu-1').css({ 'opacity' : (1) });
    }
});
              
            
!
999px

Console