123

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container-fluid">
 <div class="row  navigator ">
  <div class="col-md-2 brand text-center">
   <h3 class="brand-title text-uppercase">Fixed</h3>
  </div>
  <div class="col md-10 menu float-xs-right">
   <ul class="menu-list">
    <li class="menu-item menu-item-size">
     <a href="#">Brocoli</a>
    </li>
    <li class="menu-item menu-item-size">
     <a href="#">Almonds</a>
    </li>
    <li class="menu-item menu-item-size">
     <a href="#">Pears</a>
    </li>
    <li class="menu-item menu-item-size">
     <a href="#">Oranges</a>
    </li>
   </ul>
  </div>
 </div>
</div>
<div class="container">
 <div class="row text-center mt-3" style="z-index: 0;">
  <div class="col-md-2 paragraph">
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero provident debitis id eligendi nam, incidunt nulla modi eveniet labore! Quas, unde! Unde illum odit ex cum laboriosam at earum dolore?</p>

  </div>
 </div>
</div>
            
          
!
            
              /* document */
* {
 box-sizing: border-box;
 padding: 0;
 margin: 0;
}
body,
html {
 width: 100%;
 height: 100%;
 font-size: 16px;
 color: black;
}
/* navigator */
.navigator {
 background-color: rgb(206, 193, 193);
 width: 100%;
 height: auto;
 position: fixed;
 z-index: 1;
 top: 0;
}
/* brand */
.brand-title {
 margin: 0;
 padding-top: 26px;
 transition: 0.4s;
}
.brand-title-big {
 animation: brandToBig 1s forwards;
 transition: 1s;
}
.brand-title-small {
 animation: brandToSmall 1s forwards;
 transition: 1s;
}
@keyframes brandToSmall {
 from {
  padding-top: 26px;
 }
 to {
  padding-top: 16px;
 }
}
@keyframes brandToBig {
 from {
  padding-top: 16px;
 }
 to {
  padding-top: 26px;
 }
}
.brand:hover .brand-title {
 color: white;
 transition: 0.4s;
}
/* menu */
.menu-list {
 float: right;
 list-style-type: none;
 margin: 0;
}
.menu-item {
 display: inline-block;
 padding: 30px;
 transition: 1s;
}
.menu-item-size-big {
 transition: 1s;
 animation: toBig 1s backwards;
}
.menu-item-size-small {
 transition: 1s;
 animation: toSmall 1s forwards;
}

@keyframes toBig {
 from {
  padding: 20px;
 }
 to {
  padding: 30px;
 }
}

@keyframes toSmall {
 from {
  padding: 30px;
 }
 to {
  padding: 20px;
 }
}
.menu-item a {
 text-decoration: none;
 color: black;
 transition: 0.4s;
 font-weight: bold;
}
.menu-item:hover a {
 color: white;
 transition: 0.4s;
}
/* paragraph */
.paragraph {
 position: absolute;
 top: 20%;
}

            
          
!
            
              document.addEventListener(
 "DOMContentLoaded",
 function() {
  // handle menu smaller when scroll more than 200px and back initiate status when scroll less than 200px
  var brand = document.querySelectorAll(".brand-title")[0];
  var menuItem = document.querySelectorAll(".menu-item");
  var statusScrollSmall = "exceed";
  var statusScrollBig = "notPass";
  var key = 100;
  window.addEventListener("scroll", function() {
   if (this.pageYOffset > 200) {
    if (statusScrollSmall === "exceed") {
     brand.classList.add("brand-title-small");
     brand.classList.remove("brand-title-big");
     for (var index = 0; index < menuItem.length; index++) {
      menuItem[index].classList.add("menu-item-size-small");
      menuItem[index].classList.remove("menu-item-size-big");
     }
     // assign new value to when scroll more deep, won't run again
     statusScrollSmall = "notPass";
    }
    // assign initiate value
    statusScrollSmall = "exceed";
    key = 200;
   } else if (this.pageYOffset <= 300) {
    //this case run only when the above case have been run least once (use key variable to check)
    if (statusScrollBig === "notPass" && key === 200) {
     brand.classList.remove("brand-title-small");
     brand.classList.add("brand-title-big");
     for (var index = 0; index < menuItem.length; index++) {
      menuItem[index].classList.remove("menu-item-size-small");
      menuItem[index].classList.add("menu-item-size-big");
     }
     statusScrollBig = "exceed";
    }
    statusScrollBig = "notPass";
   }
  });
 },
 false
);

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

Console