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

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

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.

HTML

              
                <link href='https://fonts.googleapis.com/css?family=Cinzel' rel='stylesheet' type='text/css'>

<link href='https://fonts.googleapis.com/css?family=Nova+Square' rel='stylesheet' type='text/css'>

<link href='https://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>

<div class="s3-fixed-header">
  <ul>
    <li><a href="https://facebook.com/Shaz3ee" class="s3-button" target="_blank">See what I like</a></li>
    <li><a href="https://facebook.com/Shaz3e" class="s3-button" target="_blank">Like my Page</a></li>
    <li><a href="https://twitter.com/Shaz3e" class="s3-button" target="_blank">I am on Twitter</a></li>
    <li><a href="https://www.google.com/#q=Shaz3e" class="s3-button" target="_blank">Google Me</a></li>
    <li><a href="http://www.shaz3e.com" class="s3-button" target="_blank">S3</a></li>
  </ul>
</div>
<div class="s3-content">
  <h1>
    Fixed Header
    <span>Height</span>
    <span>Margin</span>
    <small>Hide after scrolling down 200px</small>
  </h1>
  <h2>HTML</h2
    <code>
      <pre>
        class="s3-fixed-header"
      </pre>
    </code>
  <h2>CSS</h2>
    <code>
      <pre>
        .s3-fixed{
          position:fixed;
        }

        .s3-fixed-header {
          margin:0 !important;
          top:0;
          display:block;
          width:100%;
          background:black;
          padding:0.2em 0;
        }
      </pre>
    </code>
  <h2>Javascript</h2>
    <code>
      <pre>
        var S3Header = $(window);
        var S3HeaderPosition = S3Header.scrollTop();
        var up = false;
        var newscroll;
          S3Header.scroll(function () {
            newscroll = S3Header.scrollTop();
            if (newscroll > S3HeaderPosition && !up && newscroll > 200) {
              $('.s3-fixed-header').stop().slideUp({duration:1000});
              up = !up;
              console.log(up);
            } else if(newscroll < S3HeaderPosition && up) {
              $('.s3-fixed-header').stop().slideDown({duration:1000});
              up = !up;
            }
            S3HeaderPosition = newscroll;
          });

        var s3FixedHeader = $('.s3-fixed-header');
        s3Fixed = "s3-fixed";
        $(window).scroll(function() {
          if( $(this).scrollTop()) {
            s3FixedHeader.addClass(s3Fixed);
          }else{
            s3FixedHeader.removeClass(s3Fixed);
          }
        });
      </pre>
    </code>
  
  <hr>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
              
            
!

CSS

              
                body{
  margin:0;
  font-family: 'Cinzel', serif;
}
.s3-transition{
  -webkit-transition: all 0.5s ease-out;
  -moz-transition: all 0.5s ease-out;
  -o-transition: all 0.5s ease-out;
  transition: all 0.5s ease-out;
} // .s3-transition
.s3-button{
  .s3-transition;
  color:black;
  background:white;
  padding:0.5em 1em;
  border-radius:10px;
  text-decoration:none;
  &:hover{
    color:white;
    background:red;
  } // hover
  &:active{
    color:black;
    background:tomato;
  } // active
} // .s3-buton close
.s3-fixed{
  position:fixed;
}
.s3-fixed-header {
  margin:0 !important;
  top:0;
  display:block;
  width:100%;
  background:black;
  padding:0.2em 0;
  ul{
    text-align:center;
    li{
      display:inline-block;
      a{
        .s3-button;
      } // a
    } // li
  } // ul
} //.s3-header close


.s3-content {
  margin:auto;
  width:800px;
  display: block;
  h1{
    text-align:center;
    span{
      padding-bottom:0.3em;
      border-bottom:solid 1px;
      font-family: 'Nova Square', cursive;
      font-size:60%;
      &:nth-child(1){
        color:red;
        &:before{
          color:gray;
          content:"Without ";
        } // before
        &:after{
          color:gray;
          content:"!";
        } // after
      } // nth-child(1)
      &:nth-child(2){
        color:gray;
        &:before{
          color:black;
          content:"Without ";
        } // before
        &:after{
          color:red;
          content:"!";
        } // after
      } // nth-child(2)
    } // span
    small{
      position:fixed;
      right:0;
      //z-index:-99;
      font-family: 'Shadows Into Light', cursive;
      color:white;
      background:red;
      font-size:50%;
      display:block;
      padding:0.5em;
    } // small
  } // h1
  h2{
    padding:0.3em;
    border-bottom:solid 2px gray;
    color:red;
  } // h2
  p{
    margin:0;
    padding:0.3em;
    border-bottom:solid 1px gray;
    &:before{
      color:red;
      content:"// ";
      font-size:20px;
    } // before
    &:after{
      color:red;
      content:" ...";
      font-size:20px;
    } // after
  } // p
} // .s3-content


// Code Styles
.s3-code{
  color:gray;
}
              
            
!

JS

              
                var S3Header = $(window);
var S3HeaderPosition = S3Header.scrollTop();
var up = false;
var newscroll;

S3Header.scroll(function () {
  newscroll = S3Header.scrollTop();
  if (newscroll > S3HeaderPosition && !up && newscroll > 200) { // after scrolling down 200 magic will start
    $('.s3-fixed-header').stop();
    $('.s3-fixed-header').animate({top: '-100%'}, 400); // 400 is the speed of header effect
    up = !up;
    console.log(up);
  } else if(newscroll < S3HeaderPosition && up) {
    $('.s3-fixed-header').stop();
    $('.s3-fixed-header').animate({top: '0px'}, 400); // 400 is the speed of header effect
    up = !up;
  }

  S3HeaderPosition = newscroll;
});

// add/remove class which sticks the header at top
var s3FixedHeader = $('.s3-fixed-header');
s3Fixed = "s3-fixed";
$(window).scroll(function() {
  if( $(this).scrollTop()) {
    s3FixedHeader.addClass(s3Fixed);
  }else{
    s3FixedHeader.removeClass(s3Fixed);
  }
});
              
            
!
999px

Console