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

              
                <div class="wrap-all-the-things">
  <header class="main-head">
    <h1>Header</h1>
    <nav>Home | About | Portfolio | Contact</nav>
  </header>
  <section class="main-torso">
    <article class="main-torso__group main-torso__group--margin-bottom">
      <div class="main-torso__inner">
        <h2>Scroll Down</h2>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
      </div>
    </article>
    <article class="main-torso__group main-torso__group--margin-bottom">
      <div class="main-torso__inner">
        <h2>Keep Scrolling</h2>
        <p>Pellentesque ut neque. Etiam sit amet orci eget eros faucibus tincidunt. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Cras varius. Nam at tortor in tellus interdum sagittis.</p>
        <p>Phasellus ullamcorper ipsum rutrum nunc. Etiam feugiat lorem non metus. In hac habitasse platea dictumst. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Curabitur suscipit suscipit tellus.</p>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
      </div>
    </article>
    <article class="main-torso__group">
      <div class="main-torso__inner">
        <h2>Almost There</h2>
        <h3><em>There's a sticky section just under this one that will become fixed to the bottom of the screen once it's fully in view.</em></h3>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
      </div>
    </article>
    <article id="js-foot-cta" class="main-torso__group foot-cta">
      <a href="javascript:void(0);" class="foot-cta__link">Sticky Stopper</a>
    </article>
    <article class="main-torso__group">
      <div class="main-torso__inner">
        <h2>But Wait: There's More</h2>
        <h3>Keep on scrolling...</h3>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
      </div>
    </article>
    <article class="main-torso__group">
      <div class="main-torso__inner">
        <h2>Check Out the Footer</h2>
        <h3><em>Once it comes into view, the sticky section becomes fixed to the top of the footer.</em></h3>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
        <p>Pellentesque posuere. Integer tincidunt. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Sed libero. Etiam feugiat lorem non metus.</p>
        <p>Etiam iaculis nunc ac metus. Praesent vestibulum dapibus nibh. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Morbi ac felis. Nam eget dui.</p>
      </div>
    </article>
  </section>
  <footer id="js-foot" class="main-foot">
    <p><strong>Footer</strong></p>
    <p>Pretty Cool, Huh?</p>
    <nav>Home | About | Portfolio | Contact</nav>
  </footer>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Raleway:400,900);
$vert-margin: 5em;
/*------------------------------------*\
    ::Page Footer CTA Template Part
\*------------------------------------*/
.foot-cta {
  position: relative;
  z-index: 50;
  height: $vert-margin;
  text-align: center;
}
.foot-cta--sticky {
  .foot-cta__link {
    position: fixed;
    bottom: 0;
  }
}
.foot-cta__link {
  position: absolute;
  left: 0;
  width: 100%;
  height: $vert-margin;
  background-color: rgba(#6D9F94,.8);
  line-height: 2.5;
  color: #FCFEBE;
  text-decoration: none;
  transition: 300ms;
  &:hover {
    background-color: rgba(#FCFEBE,.8);
    color: #C9AF59;
  }
}
html, body {
  height: 99.99999%;
}
.wrap-all-the-things {
  display: table;
  table-layout: fixed;
  height: 100%;
  width: 100%;
  background-color: #215D6E;
  color: #FCFEBE;
  font-family: "Raleway", "Trebuchet MS", sans-serif;
}
.main-head, .main-torso, .main-foot, .foot-cta__spacer {
  display: table-row;
}
.main-head {
  background-color: #387179;
  text-align: center;
  &:after {
    content: "";
    background-color: #6D9F94;
    height: .2em;
    width: 100%;
    margin-top: 5em;
    display: block;
  }
}
.main-torso {
  height: auto;
  background-color: #215D6E;
  p {
    color: #6D9F94;
  }
  h3 {
    font-weight: 100;
  }
}
.main-foot {
  background-color: #387179;
  text-align: center;
  &:before {
    content: "";
    background-color: #6D9F94;
    height: .2em;
    width: 100%;
    margin-bottom: 5em;
    display: block;
  }
}
[class*="__inner"] {
  max-width: 1140px;
  margin: {left: auto; right: auto;}
  padding: {left: 1em; right: 1em;}
}
[class*="--margin-bottom"] {
  margin-bottom: $vert-margin;
}
              
            
!

JS

              
                //prepost jquery plugin
(function($) {
  $.fn.stickystop = function(options) {
    var stick = {
        //prepare to store jquery objects
        win: null,
        cta: null,
        stopper: null,
        //to store timer
        timer: null,
        //to store options
        //options passed into the plugin
        opt: $.extend({
          //the inner element
          inner: '> :first-child',
          //the stopper element
          stopper: '.stickystop__stopper'
        }, options),
        //initialize the sticky cta
        init: function(stickEl){
            stick.cta = stickEl;
            if(stick.cta.length  > 0){
                //cache variables
                stick.win = $(window);
                stick.inner = stick.cta.find(stick.opt.inner);
                stick.stopper = $(stick.opt.stopper);

                stick.stopper.before('<div class="foot-cta foot-cta__spacer"><!-- spacer for sticky cta --></div>');
                //work on scroll
                stick.win.on('scroll',function(){
                    //be at least a little more performant
                    clearTimeout(stick.timer);
                    stick.timer = setTimeout(stick.move, 5);
                });
            }
        },
        //when the user scrolls
        move: function(){
            // get the top
            var winTop = stick.win.scrollTop();
            // get the bottom
            var winBot = winTop + stick.win.height();
            // get the cta top
            var ctaTop = stick.cta.offset().top;
            // get the cta bottom
            var ctaBot = ctaTop + stick.cta.height();
            // get the stopper top
            var stopperTop = stick.stopper.offset().top;
            // if the cta's bottom is in view and the top of the stopper isn't
            if(ctaBot <= winBot && winBot <= stopperTop){
                // make the cta sticky (to the bottom)
                stick.cta.addClass('foot-cta--sticky');
                stick.inner.css('top', 'auto');
            // if the top of the footer is in view
            } else if (winBot > stopperTop){
                // absolute position the cta above the stopper
                stick.cta.removeClass('foot-cta--sticky');
                stick.inner.css('top', (stopperTop - ctaBot));
            // if the bottom of the cta is not in view
            } else {
                // absolute position the cta at the top of it's origin
                stick.cta.removeClass('foot-cta--sticky');
                stick.inner.css('top', 0);
            }
        }
    };
    //initialize the slider for the object passed in
    stick.init(this);
  };
}(jQuery));

//call prepostslider on an element (all options set to default)
jQuery(function($){
  $('#js-foot-cta').stickystop({
    //inner: '.foot-cta__link', //defaults to '> :first-child'
    stopper: '#js-foot' //defaults to .stickystop__stopper
  });
});
              
            
!
999px

Console