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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <div class="header">
  <h1 class="header_logo">Resizing Fixed Header</h1>
</div>
<div class="offset">
  <p>Scroll down to initiate resizing of the page header.</p>
</div>
            
          
!
            
              body {
  height: 1500px;
  background: url(https://www.brainpickings.org/wp-content/themes/brainpickings/images/bckgd_body.png);
}

.offset {
  margin-top: 0;
  padding-top: 270px;
  text-align: center;
  transition: .3s;
}

.header {
  position: fixed;
  width: 100%;
  height: 250px;
  font-weight: bold;
  text-align: center;
  background: gold;
  transition: .3s;
  // header shrinks when .small added to .header
  &.small {
    height: 70px;
    box-shadow: 0 0 5px rgba(black, .2);
    // when header.small also change page offset
    & ~ .offset {
      padding-top: 140px;
    }
    // when header.small change logo pad & font size
    .header_logo {
      padding-top: 20px;
      font-size: 20px;
      text-shadow: none;
    }
  }
}

.header_logo {
  font-family: 'Oswald', sans-serif;
  margin: 0;
  padding-top: 80px;
  font-size: 50px;
  text-shadow: 3px 4px rgba(black, .1);
  transition: .3s;
}
            
          
!
            
              $(document).scroll(function() {
  navbarScroll();
});

function navbarScroll() {
  var y = window.scrollY;
  if (y > 10) {
    $('.header').addClass('small');
  } else if (y < 10) {
    $('.header').removeClass('small');
  }
}
            
          
!
999px
Loading ..................

Console