css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <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>
            
          
!
            
              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;
}
            
          
!
            
              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
🕑 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.
Loading ..................

Console