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.

            
              <link href="https://fonts.googleapis.com/css?family=Lato:100,300, 900,900i" rel="stylesheet">
<div id="nav">
  <h1>Side Menu bar</h1>
  <ul>
    <li class="active"><a href="#section1">What</a></li>
    <li><a href="#section2">When</a></li>
    <li><a href="#section3">Where</a></li>
    <li><a href="#section4">if</a></li>
    <li><a href="#section5">A</a></li>
    <li><a href="#section6">Comes</a></li>
  </ul>
    <a href="#" class="navBtn">Open</a>
</div>
<div id="contants">
  <div id="section1">What good is <strong>love</strong> and peace on earth?</div>
  <div id="section2">When it's <strong>exclusive?</strong></div>
  <div id="section3">Where's the <strong>truth</strong> in the written word?</div>
  <div id="section4">If no one  <strong>reads</strong> it</div>
  <div id="section5">A new <strong>day</strong> dawning</div>
  <div id="section6">Comes without <strong>warning</strong></div>
</div>


            
          
!
            
              #contants {text-align: center; color:#fff; font-size: 60px;}
#contants>div {height: 100vh;line-height: 100vh; font-family: 'Lato', sans-serif; font-weight:100;}
#contants strong {font-weight:900i; font-style:Italic; font-size:70px;}
#section1 {background: radial-gradient(ellipse farthest-corner at center top, #f8bfa4 0%, #f33b4e 100%);}
#section2 {background: radial-gradient(ellipse farthest-corner at left top, #FDA3BD 0%, #D5D9E5 100%)}
#section3 {background: radial-gradient(ellipse farthest-corner at right top, #00A8C5 0%, #FFFF7E 100%)}
#section4 {background: radial-gradient(ellipse farthest-corner at bottom left, #E3ADD1 0%, #B4ADE2 100%)}
#section5 {background: radial-gradient(ellipse farthest-corner at bottom center, #1D7FBF 0%, #DEC2CE 100%)}
#section6 {background: radial-gradient(ellipse farthest-corner at bottom right, #363975 0%, #688FB3 100%);}


/* nav */
#nav {position: fixed; left: -300px; top: 0; width: 300px; height: 100vh; background-color: rgba(255,255,255,0.5); font-family: 'Lato', sans-serif; font-weight:100}
#nav h1 {padding : 60px 20px 40px 20px; color: #fff; font-size: 30px; }
#nav.open {left:0;}
#nav li {border-left:5px solid transparent;}
#nav li a {color:#fff; text-decoration:none; padding:14px 20px; display:block; text-transform:uppercase; font-weight:300; }
#nav li.active {background-color:rgba(255,255,255,0.4); border-left:5px solid #fff;}

#nav .navBtn {position: absolute; right: -60px; top: 10px; width: 50px; width: 50px; display: block; background-color:rgba(255,255,255,0.4); border-radius:50%; text-align: center; line-height: 50px; color:#fff; font-weight: 300; font-size: 14px; text-decoration:none;}

            
          
!
            
              var sideBar = $("#nav");
var navBtn = $(".navBtn");
var nav = $("#nav ul li");
var contents = $ ("#contants > div");

navBtn.click(function(){
  // sideBar.css("left","-300px")
  // sideBar.toggleClass("open");
  sideBar.toggleClass("active");
  
  if(sideBar.hasClass("active")){
   sideBar.animate({ "left":"0px"},250,"easeInBounce");
   navBtn.text("close");
  }else { 
    sideBar.animate({ "left":"-300px"},200,"easeInOutCirc");
         navBtn.text("open");
 }
});
nav.click(function(e){
  e.preventDefault();
  
   var target = $(this);
   var index = target.index();
   var section = contents.eq(index);
   var offset = section.offset().top;
   $("html,body").animate({ scrollTop:offset },400);
   // alert(index);
});

$(window).scroll(function(){
  var wScroll = $(this).scrollTop();
  
  if(wScroll >= contents.eq(0).offset().top){
    nav.removeClass("active");
    nav.eq(0).addClass("active");
  } 
    if(wScroll >= contents.eq(1).offset().top){
    nav.removeClass("active");
    nav.eq(1).addClass("active");
  }
    if(wScroll >= contents.eq(2).offset().top){
    nav.removeClass("active");
    nav.eq(2).addClass("active");
  }
    if(wScroll >= contents.eq(3).offset().top){
    nav.removeClass("active");
    nav.eq(3).addClass("active");
  }
    if(wScroll >= contents.eq(4).offset().top){
    nav.removeClass("active");
    nav.eq(4).addClass("active");
  }
});






            
          
!
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