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.

            
              %nav
  .container
    #icon.fontawesome-cog
    %ul
      %li
        %a{href: "#"} Item 1
      %li
        %a{href: "#"} Item 2
      %li
        %a{href: "#"} Item 3
      %li
        %a{href: "#"} Item 4
      %li
        %a{href: "#"} Item 5
%header
  .container
    %h1 Opacity on scroll
#nav-bg
%section#about
  .container
    %p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vel diam lacus. Nam quis ipsum nec massa sagittis scelerisque ac non urna. Phasellus posuere orci ac tellus interdum mollis eu vitae mi. Aliquam nec ante lobortis, suscipit lectus eu, dignissim ante. Nam imperdiet quis eros.
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);

@import url(http://weloveiconfonts.com/api/?family=fontawesome);

[class*="fontawesome-"]:before {
  font-family: 'FontAwesome', sans-serif;
}

* {
  box-sizing: border-box;
  &:before, &:after {
    box-sizing: border-box;
  }
}

body {
  background: #222;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  color: #FFF;
}

.container {
  max-width: 60em;
  min-width: 45em;
  margin: 0 auto;
  padding: 0 2em;
}

nav {
  position: fixed;
  width: 100%;
  margin: 0 auto;
  top: 0;
  z-index: 3;
  ul {
    padding: 0;
    margin: 0;
    list-style-type: none;
    float: right;
  }
  li {
    display: inline-block;
    padding: 2em;
    text-align: center;
    transition: all .2s;
    &:last-child {
      padding-right: 0;
    }
  }
  a {
    color: #FFF;
    text-decoration: none;
    transition: all .3s;
    &:hover {
      color: #DDD;
    }
  }
}

#icon {
  display: inline-block;
  padding-top: .7em;
  font-size: 2em;
  font-weight: 700;
  text-transform: uppercase;
}

#nav-bg {
  background: #222;
  position: fixed;
  height: 5em;
  width: 100%;
  top: 0;
  z-index: 1;
}

header {
  position: relative;
  background-color: #FD7777;
  padding: 10em 0 8em;
  z-index: 2;
  h1 {
    font-size: 4em;
    text-transform: uppercase;
    text-align: center;
  }
}

#about {
  background: #E7E3DA;
  height: 70em;
  padding: 5em 0;
  p {
    line-height: 2em;
    font-size: 1.4em;
    margin: 0;
    color: #222;
  }
}
            
          
!
            
              var header = $('header');
var range = 200;

$(window).on('scroll', function () {
  
  var scrollTop = $(this).scrollTop(),
      height = header.outerHeight(),
      offset = height / 2,
      calc = 1 - (scrollTop - offset + range) / range;

  header.css({ 'opacity': calc });

  if (calc > '1') {
    header.css({ 'opacity': 1 });
  } else if ( calc < '0' ) {
    header.css({ 'opacity': 0 });
  }
  
});
            
          
!
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