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.

            
              <link href="https://fonts.googleapis.com/css?family=Archivo:400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

<div id="nav">
  <h2>JJGODCOM</h2>
  <ul>
      <li><a href="#section1">menu1</a></li>
      <li><a href="#section2">menu2</a></li>
      <li><a href="#section3">menu3</a></li>
      <li><a href="#section4">menu4</a></li>
      <li><a href="#section5">menu5</a></li>
      <li><a href="#section6">menu6</a></li>
   </ul>        
</div>

<div id="contents">
  <div id="section1">We love What You do.</div>
  <div id="section2">love What You do.</div>
  <div id="section3">What You do.</div>
  <div id="section4">Can I get a ride?</div>
  <div id="section5">Call me Sam, please.</div>
  <div id="section6">Couldn't be better than this.</div>
</div>
            
          
!
            
              #nav {
  overflow:hidden; position: fixed; left: 0; top: 0; width: 100%;background-color: rgba(255,255,255,0.6);
}
#nav h2 { float:left; color:#fff; font-size: 40px; padding:12px 5px 5px 20px; font-weight:700;
  float:left;
}
#nav ul {
  float: right;
  padding: 10px;
}
#nav ul li {
  display:inline;
  border-top : 5px solid transparent;
}
#nav li.active {
   padding:5px;
   border-bottom:2px solid #fff;
}
#nav ul li a {
  padding:10px; text-decoration: none; color:#fff; display:inline-block;
   text-transform: uppercase;
}


#contents {
  text-align: center; font-size: 40px;       color:#fff; line-height: 100vh; 
  font-family: 'Archivo', sans-serif;
  font-weight: 400i;
}
#contents > div {
  height: 100vh;
}
#section1 {
  background-color: #1a237e;
}
#section2 {
  background-color: #0d47a1;
}
#section3 {
  background-color: #311b92;
}
#section4 {
  background-color: #01579b;
}
#section5 {
  background-color: #006064;
}
#section6 {
  background-color: #004d40;
}
            
          
!
            
              var nav = $("#nav ul li");
var contents = $("#contents > div");
var body =$("body")

nav.click(function(){
  var target = $(this);     //6개의 버튼 target을 할당
  var index = target.index(); //6개 버튼에 인텍스 할당
  //alert(index)
  var section = contents.eq(index); //6개의 컨텐츠에 인덱스 할당
  var offset = section.offset().top; //6개의 컨텐츠의 offset 값을 할당
  //alert(offset)
  $("html, body").animate({ scrollTop:offset},400);
});

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);
});

$(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");
   }
   if(wScroll >= contents.eq(5).offset().top){
      nav.removeClass("active");
      nav.eq(5).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