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

              
                <!--hdrTp-->
	<div class="flex flexCenterItems flexFlexEnd hdrTp">
	
		
	<div class="flex flexCenterItems flexFlexEnd navIconWrap">
		
		<div class="navIcon">
	<svg version="1.1" id="navIcon-customer-resources" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 28 22" style="enable-background:new 0 0 28 22;" xml:space="preserve"><g><polygon class="navIconClr" points="6.4,15.7 11.2,20.5 11.2,15.7 "/><path class="navIconClr" d="M20.4,1.8H7.6c-0.6,0-1.1,0.5-1.1,1.1v10.8c0,0,0,0,0,0h6.1c0.3,0,0.6,0.3,0.6,0.6v6.2c0,0,0,0,0,0h7.4c0.6,0,1.1-0.5,1.1-1.1V2.9C21.6,2.3,21.1,1.8,20.4,1.8z M17.8,11.8h-5.3c-0.3,0-0.6-0.3-0.6-0.6c0-0.3,0.3-0.6,0.6-0.6h5.3c0.3,0,0.6,0.3,0.6,0.6C18.3,11.6,18.1,11.8,17.8,11.8z M17.8,8.7h-5.3c-0.3,0-0.6-0.3-0.6-0.6c0-0.3,0.3-0.6,0.6-0.6h5.3c0.3,0,0.6,0.3,0.6,0.6C18.3,8.5,18.1,8.7,17.8,8.7z M17.8,5.4h-5.3c-0.3,0-0.6-0.3-0.6-0.6c0-0.3,0.3-0.6,0.6-0.6h5.3c0.3,0,0.6,0.3,0.6,0.6C18.3,5.1,18.1,5.4,17.8,5.4z"/></g></svg>
		</div>
		
		<div class="navIcon">
	<svg version="1.1" id="navIcon-find" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 28 22" style="enable-background:new 0 0 28 22;" xml:space="preserve"><path class="navIconClr" d="M6.6,8.7c0-4.1,3.3-7.4,7.4-7.4s7.4,3.3,7.4,7.4c0,5.5-7.4,12-7.4,12S6.6,14.1,6.6,8.7z M14,11.9c2,0,3.6-1.6,3.6-3.6S16,4.7,14,4.7s-3.6,1.6-3.6,3.6S12,11.9,14,11.9z"/></svg>
		</div>
	
		<div class="navIcon">
	<svg version="1.1" id="navIcon-search" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 28 22" style="enable-background:new 0 0 28 22;" xml:space="preserve"><g><path class="navIconClr" d="M12.3,4.7c2.4,0,4.3,1.9,4.3,4.3s-1.9,4.3-4.3,4.3S8,11.4,8,9.1S9.9,4.7,12.3,4.7 M12.3,1.4c-4.2,0-7.6,3.4-7.6,7.6s3.4,7.6,7.6,7.6s7.6-3.4,7.6-7.6S16.5,1.4,12.3,1.4L12.3,1.4z"/><g><path class="navIconClr" d="M20.2,20.4l-5.3-5.3l2.5-2.5l5.3,5.3c0.6,0.6,0.6,1.5,0,2.1l-0.4,0.4C21.7,21,20.8,21,20.2,20.4z"/></g></g></svg>
		</div>
	
		<div class="navIcon">
	<svg version="1.1" id="navIcon-customer-relations" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 28 22" style="enable-background:new 0 0 28 22;" xml:space="preserve"><g><g><polygon class="navIconClr" points="14,0.9 0.6,8.7 27.5,8.7 "/></g><g><rect x="2.2" y="9.2" class="navIconClr" width="23.6" height="1.7"/></g><g><rect x="2" y="18.6" class="navIconClr" width="24.1" height="1.8"/></g><g><path class="navIconClr" d="M26.3,19.7H1.7c-0.2,0-0.4,0.2-0.4,0.4v0c0,0.2,0.2,0.4,0.4,0.4h24.7c0.2,0,0.4-0.2,0.4-0.4v0C26.8,19.9,26.6,19.7,26.3,19.7z"/></g><g><g><g><rect x="3.9" y="13.9" class="navIconClr" width="3.8" height="6.2"/></g><g><path class="navIconClr" d="M8.2,13.4H3.3c-0.2,0-0.4-0.2-0.4-0.4v-1.5h5.7v1.5C8.6,13.2,8.4,13.4,8.2,13.4z"/></g></g><g><g><rect x="12.1" y="13.9" class="navIconClr" width="3.8" height="6.2"/></g><g><path class="navIconClr" d="M16.4,13.4h-4.8c-0.2,0-0.4-0.2-0.4-0.4v-1.5h5.7v1.5C16.9,13.2,16.7,13.4,16.4,13.4z"/></g></g><g><g><rect x="20.2" y="13.9" class="navIconClr" width="3.8" height="6.2"/></g><g><path class="navIconClr" d="M24.5,13.4h-4.8c-0.2,0-0.4-0.2-0.4-0.4v-1.5H25v1.5C25,13.2,24.8,13.4,24.5,13.4z"/></g></g></g></g></svg>
		</div>
		
		<div class="navIcon">
	<svg version="1.1" id="navIcon-phone" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 28 22" style="enable-background:new 0 0 28 22;" xml:space="preserve"><path class="navIconClr" d="M6.9,2C6.5,2.1,6.2,2.4,6.1,2.8C5.9,4.6,5.7,9.6,9.6,14.5c4,4.9,9.4,6,11.3,6.2c0.4,0.1,0.9-0.2,1-0.6l1.2-3.7c0.1-0.5,0-1-0.5-1.2L18.8,13c-0.5-0.3-1.1-0.1-1.4,0.3l-1.4,2.2c0,0-2.2-1.3-3.6-3s-2.3-3.8-2.3-3.8l2.2-1.4C12.9,7,13,6.5,12.9,6.1L11.5,2c-0.2-0.5-0.7-0.8-1.2-0.7L6.9,2z"/></svg>
		</div>
		
		<a href=""><div class="navSignIn">Sign In</div></a>
		
		</div><!--END navIconWrap -->
		
	</div><!--END hdrTp -->

<!--hdr-->
	<div class="hdrWrap">
	<div class="flex flexCenter hdr">
		
		<div class="flex flexCenterItems hdrLogo">
		
		</div>
		
	  <div class="flex flexCenterItems flexFlexEnd hdrNav">
		  <ul class="mainNavUL">
			  <li class="mainNavItem">Item 1</li>
			    <li class="mainNavItem">Item 2</li>
			    <li class="mainNavItem">Item 3</li>
			   <li class="mainNavItem">Item 4</li>
		  </ul>
		</div>
		
	</div><!--END hdr -->
		</div><!--END hdrWrap -->

<div class="content" id="scroll-container">
<div class="flex flexCenter flexColumnStack mainHero">
</div>
</div> 
              
            
!

CSS

              
                body{background-color:black;}
*{box-sizing: border-box; margin:0; padding:0;}
a{text-decoration: none; color:#333; cursor: pointer;}

.mainHero{width:100%; height:2000px; background-color:teal; background-image: url("https://www.micelistudios.com/imgs/test-img.jpg"), linear-gradient(to right, #0c6f5f, #005660); background-repeat: no-repeat; background-position: center; /* margin-top:184px;  margin-top to compensate for height of fixed hdr height */ }

/*   SVGs  */
.navIconClr{fill:#93B7E1;}
.navIconClr:hover{fill:#5bc59a;}

/*   top navigation icons  */
.navIconWrap{width:100%; max-width:1260px; margin:0 auto; padding-right:40px;}
.navIcon {width:28px; height:22px; margin-right:30px;}
.navIcon:nth-child(5){margin-right:0px !important;}
.navSignIn{height:28px; padding:8px 28px; background-color:#93b7e1; color:#23497a; font-family: 'Open Sans', sans-serif; font-weight:bold; text-align:center; font-size:13px; line-height:13px; border-radius:2px; letter-spacing: 2; margin-left:38px;}
.navSignIn:hover{background-color:#5bc59a;}


/*  text  */
sup {font-size:33%;}

/*   flex   */
.flex { display: -webkit-box;display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex;}
.flexCenter {-webkit-align-content: center; -webkit-justify-content: center; align-content: center;justify-content: center;} /* remove for equal height cols */
.flexCenterItems{align-items: center;}
.flexFlexEnd{justify-content: flex-end;}
.flexTopItems{align-items: flex-start;}
.rowWrap {flex-flow: row wrap;-webkit-flex-flow: row wrap;}
.flexColumnStack{flex-direction: column; margin:0 auto;}
.flexInner {}
.flexVerticalCenter{display: flex;flex-direction: column;justify-content: center;}

/* nav */
.mainNavItem{font-family: 'Open Sans', sans-serif; font-weight:600; text-align:left; text-transform: uppercase; list-style: none; display:inline-block; color: #333333; font-size:14px; line-height:21px; padding-right:44px;}
.mainNavItem:last-child {padding-right:0px;}

/*  hero and hdr */
.hdrTp{width:100%; height: 60px; background-color:#23497a; position: fixed; top:0; z-index:2;}
.hdrWrap{width:100%; height: 124px; margin:0 auto; background-color:#ffffff; position: fixed; top:0; z-index:2; /* margin-top:60px;  margin-top to compensate for height of fixed hdrTp height */ box-shadow: 1px 1px 24px 1px rgba(0, 0, 0, 0.1);}
.hdr{width:100%; max-width:1260px; height: 124px; margin:0 auto; background-color:transparent;}
.hdrLogo{width:30%; background-color:transparent; padding-left:40px;}
.hdrLogo img{margin-top:3px;}
.hdrNav{width:70%; background-color:transparent; padding-right:40px;}
.hdrPhoneTxt, .hdrPhoneTxt a{font-family: 'Open Sans', sans-serif; font-size:18px; line-height:18px; font-weight:bold; color:#23497a; padding-left:10px; letter-spacing: 1px;}
              
            
!

JS

              
                /*
// smooth scrolling
console.clear();

gsap.registerPlugin(ScrollTrigger);

var container = document.querySelector("#scroll-container");

var height = container.clientHeight;
document.body.style.height = height + "px";

gsap.to(container, {
  y: -(height - document.documentElement.clientHeight),
  scrollTrigger: {
    trigger: document.body,
    start: "top top",
    end: "bottom bottom",
    scrub: 1
  }
});
*/

gsap.set(".hdr, .hdrWrap, .hdrTp", {transformOrigin: "top left"});


// Move these elements down in gsap,
// because the header is fixed and takes up room.
// Replace margin-top in the css.Scrolling is jittery with marginTop animated.
gsap.set(".content", {y:184});
gsap.set(".hdrWrap", {y:58});

var lastScrollTop = 0;
var bottomsUp = document.body.scrollHeight;

const tl = gsap.timeline({
  defaults: {duration: .25, ease: "none"},
	scrollTrigger: {
	scrub:false,
    end: 999999,
    onUpdate: scroll => {
      let position = scroll.scroll();
       
      if (position === 0) {
        scrollToTop();
	   
	   } else if (position < lastScrollTop) {
        scrollUp();
        
      } else if (position > lastScrollTop) {
        scrollDown();

      }

      lastScrollTop = position <= 0 ? 0 : position;
    }
  }

});
// gsap timeline
function scrollDown(){
var tl = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl.to(".hdr, .hdrWrap", {height: 70}, "0")
      .to(".hdrWrap", {y: 8}, "0")
      .to(".content", {y: 104}, "0")
      //.to(".hdrTp", {height: 10}, "0")
      .to(".navIconWrap", {opacity:0}, "0");
    return tl;
};

function scrollUp(){
var tl2 = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl2.to(".hdr, .hdrWrap", {height: 80}, "0")
        .to(".hdrWrap", {y: 58}, "0")
        .to(".content", {y: 124}, "0")
        //.to(".hdrTp", {height: 60}, "0")
        .to(".navIconWrap", {opacity:1}, "0");
    return tl2;
};

function scrollToTop(){
var tl3 = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl3.to(".hdr, .hdrWrap", {height: 124}, "0")
        .to(".hdrWrap", {y: 58}, "0")
        .to(".content", {y:184}, "0")
        //.to(".hdrTp", {height: 60}, "0")
        .to(".navIconWrap", {opacity:1}, "0");
    return tl3;
};

/*
let lastScrollTop = 0;

const tl = gsap.timeline({
  defaults: {duration: .25, ease: "none"},
scrollTrigger: {
  scrub:false,
    end: 99999999,
    onUpdate: scroll => {
      let position = scroll.scroll();
      console.log(position);
      
      if (position === 0) {
         //tl.reverse()
        scrollToTop();
     
      } else if (position < lastScrollTop) {
      //tl.reverse("pauseHere")
        scrollUp();
        
      } else if (position > lastScrollTop) {
        //tl.play();
        scrollDown();
      }

      lastScrollTop = position;
    }
  }

});


// gsap timeline
function scrollDown(){
var tl = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl.to(".hdr, .hdrWrap", {height: 70}, "0")
      .to(".hdrWrap", {marginTop: 10}, "0")
      .addLabel("pauseHere")
      .to(".mainHero", {marginTop: 90}, "0")
      .to(".hdrTp", {height: 10}, "0")
      .to(".navIconWrap", {opacity:0}, "0");
    return tl;
};

function scrollUp(){
var tl2 = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl2.to(".hdr, .hdrWrap", {height: 80}, "0")
        .to(".hdrWrap", {marginTop: 60}, "0")
        .to(".mainHero", {marginTop: 140}, "0")
        .to(".hdrTp", {height: 60}, "0")
        .to(".navIconWrap", {opacity:1}, "0");
    return tl2;
};

function scrollToTop(){
var tl3 = gsap.timeline({defaults: {duration: .25, ease: "none"}});
    tl3.to(".hdr, .hdrWrap", {height: 124}, "0")
        .to(".hdrWrap", {marginTop: 60}, "0")
        .to(".mainHero", {marginTop: 184}, "0")
        .to(".hdrTp", {height: 60}, "0")
        .to(".navIconWrap", {opacity:1}, "0");
    return tl3;
};
*/


/*
window.addEventListener("scroll", function(){
   var st = window.pageYOffset || document.documentElement.scrollTop;
  if(st === 0){
    // when the window reaches the top
  gsap.to(".hdr, .hdrWrap", {duration:.25, height: 124, overwrite:true});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 60});
	gsap.to(".mainHero", {duration:.25, marginTop: 184});
	gsap.to(".hdrTp", {duration:.25, height: 60});
	gsap.to(".navIconWrap", {duration:.25, opacity:1, overwrite:true});
	  
  } else if (st > lastScrollTop) {
    // down-scroll code
   gsap.to(".hdr, .hdrWrap", {duration:.25, height: 70});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 10});
	gsap.to(".mainHero", {duration:.25, marginTop: 90});
	gsap.to(".hdrTp", {duration:.25, height: 10});
	gsap.to(".navIconWrap", {duration:.25, opacity:0});

  } else if (st < lastScrollTop) {
    // up-scroll code
   gsap.to(".hdr, .hdrWrap", {duration:.25, height: 80, overwrite:true});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 60});
	gsap.to(".mainHero", {duration:.25, marginTop: 140, overwrite:true});
	gsap.to(".hdrTp", {duration:.25, height: 60, overwrite:true});
	gsap.to(".navIconWrap", {duration:.25, opacity:1, overwrite:true});
  }
  
   lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
}, false);

*/

/* scrollTrigger */
//onUpdate: self => {const st = self.scroll();}


/*
var lastScrollTop = 0;

window.addEventListener("scroll", function(){
  let st = ScrollTrigger.create({trigger: ".hdr"});
  let position = st.scroll();
  if(position === 0){
    // when the window reaches the top
  gsap.to(".hdr, .hdrWrap", {duration:.25, height: 124, overwrite:true});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 60});
	gsap.to(".mainHero", {duration:.25, marginTop: 184});
	gsap.to(".hdrTp", {duration:.25, height: 60});
	gsap.to(".navIconWrap", {duration:.25, opacity:1, overwrite:true});
	  
  } else if (position > lastScrollTop) {
    // down-scroll code
   gsap.to(".hdr, .hdrWrap", {duration:.25, height: 70});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 10});
	gsap.to(".mainHero", {duration:.25, marginTop: 90});
	gsap.to(".hdrTp", {duration:.25, height: 10});
	gsap.to(".navIconWrap", {duration:.25, opacity:0});

  } else if (position < lastScrollTop) {
    // up-scroll code
   gsap.to(".hdr, .hdrWrap", {duration:.25, height: 80, overwrite:true});
	gsap.to(".hdrWrap", {duration:.25, marginTop: 60});
	gsap.to(".mainHero", {duration:.25, marginTop: 140, overwrite:true});
	gsap.to(".hdrTp", {duration:.25, height: 60, overwrite:true});
	gsap.to(".navIconWrap", {duration:.25, opacity:1, overwrite:true});
  }
  
   lastScrollTop = position <= 0 ? 0 : st; // For Mobile or negative scrolling
}, false);

*/
              
            
!
999px

Console