Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <div style="position: relative;">
  <div class="header">
    <nav class="navbar">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
          </ul>
        </div>
      </div>
    </nav>
  </div>
</div>

<div class="container overlay">
  <div class="col-sm-7">
    <h1>This text/context should move out of the viewport with the scroll</h1>
  </div>
</div>

<div class="body">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex mauris, fermentum eget tristique ut, pulvinar ac magna. Duis urna enim, volutpat in laoreet eu, porta non enim. Sed consectetur blandit ante eget facilisis. Aliquam condimentum, mi
    interdum sodales lobortis, diam risus facilisis mauris, a commodo ante dui id justo. Duis in enim elementum, mattis risus non, auctor enim. Integer quis molestie nibh, vitae porta turpis. Etiam vel suscipit turpis, vel laoreet ipsum. Quisque quis
    urna eros.</p>

  <p>Suspendisse tincidunt tincidunt lacus, sed sagittis massa fringilla ac. Suspendisse potenti. In fermentum pulvinar dui vel tincidunt. Vivamus at sapien porta, vulputate lacus non, lobortis risus. Duis ultricies efficitur sagittis. Phasellus aliquam
    nibh at augue euismod, at vestibulum turpis gravida. In vel enim id justo porttitor gravida.</p>

  <p>Quisque elementum vitae neque ut pulvinar. Duis laoreet dui sit amet erat bibendum, sed scelerisque quam consequat. Vivamus facilisis quam consequat, fermentum lacus ac, maximus eros. Sed vulputate quam tortor, nec vulputate ligula fermentum cursus.
    Curabitur varius turpis eget leo ullamcorper scelerisque. Quisque quis condimentum est. Nulla nec fringilla mauris. Maecenas viverra ipsum ultricies libero gravida consectetur.</p>

  <p>Proin a odio purus. Donec quis condimentum quam. Nulla finibus nulla ut nunc laoreet, ut vulputate neque iaculis. Proin odio sem, maximus vel faucibus at, ultrices id odio. Morbi ut consequat lacus, sed varius dolor. Praesent malesuada libero odio,
    ut consectetur nunc egestas in. Quisque vestibulum est libero, nec commodo ligula aliquam ac. Sed sed placerat libero. Vivamus posuere porta dolor, sed efficitur lorem scelerisque in. Vestibulum at sem aliquet, volutpat dolor porta, pellentesque
    erat. Etiam rhoncus ipsum quis mauris fringilla, quis pretium tortor euismod. Praesent luctus ante nulla, ac iaculis velit pharetra in.</p>

  <p>Pellentesque a quam eget erat blandit efficitur ac et sapien. Duis vel diam placerat metus tincidunt pharetra et nec sem. Vivamus condimentum dolor at velit pharetra, vel consequat diam suscipit. Curabitur blandit velit magna, vel varius neque varius
    sed. Pellentesque eget neque vel sem rutrum dictum eget id dolor. Aliquam commodo eros non tincidunt consectetur. Proin gravida ultrices posuere.</p>

  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex mauris, fermentum eget tristique ut, pulvinar ac magna. Duis urna enim, volutpat in laoreet eu, porta non enim. Sed consectetur blandit ante eget facilisis. Aliquam condimentum, mi
    interdum sodales lobortis, diam risus facilisis mauris, a commodo ante dui id justo. Duis in enim elementum, mattis risus non, auctor enim. Integer quis molestie nibh, vitae porta turpis. Etiam vel suscipit turpis, vel laoreet ipsum. Quisque quis
    urna eros.</p>

  <p>Suspendisse tincidunt tincidunt lacus, sed sagittis massa fringilla ac. Suspendisse potenti. In fermentum pulvinar dui vel tincidunt. Vivamus at sapien porta, vulputate lacus non, lobortis risus. Duis ultricies efficitur sagittis. Phasellus aliquam
    nibh at augue euismod, at vestibulum turpis gravida. In vel enim id justo porttitor gravida.</p>

  <p>Quisque elementum vitae neque ut pulvinar. Duis laoreet dui sit amet erat bibendum, sed scelerisque quam consequat. Vivamus facilisis quam consequat, fermentum lacus ac, maximus eros. Sed vulputate quam tortor, nec vulputate ligula fermentum cursus.
    Curabitur varius turpis eget leo ullamcorper scelerisque. Quisque quis condimentum est. Nulla nec fringilla mauris. Maecenas viverra ipsum ultricies libero gravida consectetur.</p>

  <p>Proin a odio purus. Donec quis condimentum quam. Nulla finibus nulla ut nunc laoreet, ut vulputate neque iaculis. Proin odio sem, maximus vel faucibus at, ultrices id odio. Morbi ut consequat lacus, sed varius dolor. Praesent malesuada libero odio,
    ut consectetur nunc egestas in. Quisque vestibulum est libero, nec commodo ligula aliquam ac. Sed sed placerat libero. Vivamus posuere porta dolor, sed efficitur lorem scelerisque in. Vestibulum at sem aliquet, volutpat dolor porta, pellentesque
    erat. Etiam rhoncus ipsum quis mauris fringilla, quis pretium tortor euismod. Praesent luctus ante nulla, ac iaculis velit pharetra in.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex mauris, fermentum eget tristique ut, pulvinar ac magna. Duis urna enim, volutpat in laoreet eu, porta non enim. Sed consectetur blandit ante eget facilisis. Aliquam condimentum, mi
    interdum sodales lobortis, diam risus facilisis mauris, a commodo ante dui id justo. Duis in enim elementum, mattis risus non, auctor enim. Integer quis molestie nibh, vitae porta turpis. Etiam vel suscipit turpis, vel laoreet ipsum. Quisque quis
    urna eros.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex mauris, fermentum eget tristique ut, pulvinar ac magna. Duis urna enim, volutpat in laoreet eu, porta non enim. Sed consectetur blandit ante eget facilisis. Aliquam condimentum, mi
    interdum sodales lobortis, diam risus facilisis mauris, a commodo ante dui id justo. Duis in enim elementum, mattis risus non, auctor enim. Integer quis molestie nibh, vitae porta turpis. Etiam vel suscipit turpis, vel laoreet ipsum. Quisque quis
    urna eros.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex mauris, fermentum eget tristique ut, pulvinar ac magna. Duis urna enim, volutpat in laoreet eu, porta non enim. Sed consectetur blandit ante eget facilisis. Aliquam condimentum, mi
    interdum sodales lobortis, diam risus facilisis mauris, a commodo ante dui id justo. Duis in enim elementum, mattis risus non, auctor enim. Integer quis molestie nibh, vitae porta turpis. Etiam vel suscipit turpis, vel laoreet ipsum. Quisque quis
    urna eros.</p>
  <p>Pellentesque a quam eget erat blandit efficitur ac et sapien. Duis vel diam placerat metus tincidunt pharetra et nec sem. Vivamus condimentum dolor at velit pharetra, vel consequat diam suscipit. Curabitur blandit velit magna, vel varius neque varius
    sed. Pellentesque eget neque vel sem rutrum dictum eget id dolor. Aliquam commodo eros non tincidunt consectetur. Proin gravida ultrices posuere.</p>
</div>
              
            
!

CSS

              
                html, body {
  height: 100%;
  font-family: 'Roboto', sans-serif;
}

.navbar {
  float: none;
  position: absolute;
  bottom: 0;
  margin-bottom: 0px;
  width: 100%;
}

.header {
  position: fixed;
  z-index: 99;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 70px;
  background: url(//www.anony.ws/i/2015/10/28/yosemite.jpg) no-repeat center center;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

.body {
  background-color: whitesmoke;
  position: absolute;
  top: 100vh;
}

.overlay {
  position: relative;
  z-index: 100;
  height: 100px;
  color: white;
  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#000000+0,000000+100&amp;0.65+0,0+100;Neutral+Density */
  
  background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
  /* FF3.6-15 */
  
  background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
  /* Chrome10-25,Safari5.1-6 */
  
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
  /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000', GradientType=0);
  /* IE6-9 */
}

.navbar {
  -webkit-transition: all 200ms ease-in-out;
  -moz-transition: all 200ms ease-in-out;
  -ms-transition: all 200ms ease-in-out;
  -o-transition: all 200ms ease-in-out;
  transition: all 200ms ease-in-out;
  min-height: 70px;
}

.navbar.sticky {
  height: 70px;
  background-color: rgba(0, 0, 0, 0.45);
}

.navbar-nav > li > a {
  padding-top: 0px;
  padding-bottom: 0px;
  line-height: 70px;
}

@media (max-width: 767px) {
  .navbar-nav > li > a {
    line-height: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}
              
            
!

JS

              
                  $(function () {
  $(window).on("resize scroll", function () {
    var top = $(document).scrollTop();
    var viewport = $(window).height()
    $(".header").height(viewport-top);
    if ($(".header").height() <= 70){
      $(".navbar").addClass("sticky");
    }
    else {
      $(".navbar").removeClass("sticky");
    }
  });
});
              
            
!
999px
We'd ask you for an infinite loop joke, but we'd never hear the end of it.

Console