cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <header class="site-header">
  <h2 class="title">Sticky Navigation</h2>
  <p>Proceed to scroll down, please.</p>
  <span class="arrow">&downarrow; </span>
</header>
<nav class="navbar">
  <div class="container">
    <a href="#" class="brand">Sticky Navigation</a>
    <ul class="nav">
      <li><a href="#">Link 1</a></li>
      <li><a href="#">Link 2</a></li>
      <li><a href="#">Link 3</a></li>
      <li><a href="#">Link 4</a></li>
    </ul>
  </div>
</nav>
<div class="main">
  <div class="container">
    <h2>Let Thou Stick To Top.</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta similique animi dolorum earum repellendus tempora quisquam porro autem ea hic libero error fuga facilis dolore quas odio ducimus sequi adipisci mollitia ipsa impedit! Officiis magnam laborum impedit molestiae neque possimus veniam expedita accusantium excepturi ipsam voluptatum eos repellendus doloremque voluptate doloribus commodi explicabo distinctio ducimus nemo ad perspiciatis quas dicta ipsum. Ad hic repellat a architecto eaque commodi labore cupiditate corporis quibusdam porro magnam obcaecati excepturi ipsa mollitia debitis eligendi provident consequatur. Molestiae tenetur nihil quam possimus nesciunt doloribus voluptas ipsum officiis expedita commodi tempore in atque quaerat illo alias.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit enim maxime sapiente quibusdam nulla perspiciatis quas odit et reprehenderit impedit veritatis eius natus ipsum eos dolorum! Fugit quo quibusdam possimus! Consequuntur ratione dolor provident non labore eius. Unde quos facere. Commodi eaque voluptatibus inventore veniam eum totam quaerat. Voluptas suscipit.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam earum odio alias doloremque voluptatum error. Vitae nam porro voluptatum quibusdam nulla quaerat deleniti deserunt incidunt repellendus veritatis doloribus voluptate maxime quidem aliquid natus obcaecati reprehenderit cum reiciendis explicabo commodi numquam sapiente magnam. Ipsam et aliquam veniam sit inventore unde asperiores. Voluptatibus nemo officiis animi ducimus maiores voluptates cupiditate sapiente ut optio necessitatibus placeat deserunt assumenda molestias quas aliquam fuga quod nostrum incidunt mollitia quia at.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Et autem tenetur reprehenderit ipsam cupiditate repellat deserunt sint quae quas quod quibusdam iure in minus veritatis magni nesciunt sed aliquid harum?</p>
  </div>
</div>
            
          
!
            
              @import "compass/css3";

$base__font-family: "Helvetica", Sans-serif;
$base__font-size: 16;
$base__line-height: 1.6;

$heading__font-family: 'Droid Sans', 'sans-serif';

// Convert px to em
@function em($px, $base: $base__font-size) {
  @return ($px / $base) * 1em;
}

// Keyframe mixin
@mixin keyframe ($animation_name) {
    @-webkit-keyframes $animation_name {
        @content;
    }
 
    @-moz-keyframes $animation_name {
        @content;
    }
 
    @keyframes $animation_name {
        @content;
    }
}

@mixin text($family: $base__font-family, $weight: normal, $size: $base__font-size) {
  font-family: $family;
  font-weight: $weight;
  font-size: em($size);
}

@mixin clearfix() {
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

*, 
*:before,
*:after {
  margin: 0;
  @include box-sizing(border-box);
}

a {
  text-decoration: none;
  color: darken(#fff, 5%);
}

body {
  padding-top: 570px;
  @include text();
  line-height: $base__line-height;
}

.site-header {
  height: 800px;
  padding-top: 230px;
  text-align: center;
  background-color: #e67e22;
  color: darken(#fff, 5%);
  z-index: 1;
  h2 { 
    @include text($heading__font-family,700,40);
    letter-spacing: 5px;
    text-transform: uppercase;
  }
  p { letter-spacing: 2px; }
}

.navbar {
  // Adding margin-bottom eliminates the odd jumpy behavior.
  margin-bottom: -85px; 
  padding: 30px 0;
  text-transform: uppercase;
  background-color: #1d1f20;
  //background-color: rgba(29, 31, 32,.9);
  z-index: 3;
  @include clearfix;
}

.nav {
  padding: 0;
  float: right;
  li {
    padding-right: 20px;
    display: inline;
    &:last-child { padding-right: 0; }
  }
}

.main, 
.navbar { 
  position: relative; 
}

.site-header,
.nav--scrolled {
  position: fixed;
  width: 100%;
  top: 0;
}

.brand {
  @include text($heading__font-family);
  letter-spacing: 5px;
  color: #fff;
  position: relative;
  float: left;
}

.container {
  width: 90%;
  max-width: 960px;
  margin: auto;
}

.main {
  padding: 100px 0;
  background-color: #ecf0f1;
  z-index: 2; 
  p { 
    margin-bottom: 40px;
    font-size: em(18);
  }
}

.arrow {
  font-size: em(20);
  display: block;
}

.bounce {
  -webkit-animation: bounce .5s infinite ease-in-out;
  animation: bounce .5s infinite ease-in-out;
 
}

@include keyframe(bounce) {
  0%, 100% { @include transform(translateY(5px)); }
  50% { @include transform(translateY(0)); }
}
            
          
!
            
              (function ($) {
  "use strict"
  
  var $window;
  
  function stickyNavigation () {
    var $this = $(this),
        navScrolled = "nav--scrolled",
        siteHeader = $('.site-header').height(),
        navbar = $('.navbar');
    
    if($this.scrollTop() > siteHeader) {
      navbar.addClass(navScrolled);
    } else {
      navbar.removeClass(navScrolled);
    }
  } 
  
  $(function () {
    var $window = $(window);
    
    $window.scroll(stickyNavigation);
  });
})(jQuery);

/* old way
$(function() {
  var ns = "nav--scrolled",
      sh = $('.site-header').height(),
      navbar = $('.navbar');
  
  $(window).scroll(function() {
    if( $(this).scrollTop() > sh ) {
      navbar.addClass(ns);
    } else {
      navbar.removeClass(ns);
    }
  });
  
  $('.arrow').addClass('bounce');
});
*/
            
          
!
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