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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              <link href="https://fonts.googleapis.com/css?family=Saira:100, 300,700" rel="stylesheet">

<nav id="nav">
  <h1>Still, breathing</h1>
  <ul>
    <li class="active"><a href="#section1">★</a></li>
    <li><a href="#section2">☆</a></li>
    <li><a href="#section3">★</a></li>
    <li><a href="#section4">☆</a></li>
    <li><a href="#section5">★</a></li>
    <li><a href="#section6">☆</a></li>
  </ul>
</nav>

<div id="contents">
  <div id="section1">I'm like a child looking off in the horizon</div>
  <div id="section2">I'm like an ambulance that's turning on the sirens</div>
  <div id="section3">Oh, I'm still alive</div>
  <div id="section4">I'm like a soldier coming home for the first time</div>
  <div id="section5">I dodged a bullet and I walked across a landmine</div>
  <div id="section6">Oh, I'm still alive
</div>
</div>
            
          
!

CSS

            
              #nav {overflow: hidden; position: fixed; left: 0;top: 0; width: 100%; background-color:rgba(255, 255, 255, 0.5)}
#nav h1 { color:white; font-size: 40px; padding: 14px 5px 16px 20px; float: left;}
#nav ul {float: right;}
#nav ul li {display:inline;}
#nav ul li.active a {color:black}
#nav ul li a {padding: 30px; text-decoration:none; color:white; display:inline-block;}

#contents {text-align:center; font-size: 40px; color:white; font-family: 'Saira', sans-serif; font-weight:100;}
#contents>div {height:100vh; line-height:100vh;}
#section1{background-color: #D7AEB2;}
#section2{background-color: #DF6071;}
#section3{background-color: #CC4337;}
#section4{background-color: #7E6146;}
#section5{background-color: #E78979;}
#section6{background-color: #8B6C71;}
            
          
!

JS

            
              var nav =$("#nav ul li");
var contents =$("#contents>div")
var sideBar = $("#nav");

nav.click(function(e){
    e.preventDefault();
    var target= $(this); // 6개의 버튼 타켓을 변수 target에 할당
    var index=target.index();  //6개의 버튼에 인덱스의 변수를 만듬
   // alert(index);
    var section= contents.eq(index); //section에 contents의 인덱스를 할당
    var offset=section.offset().top; //6개의 컨텐츠의 offset 값을 할당
  // alert(offset);
    $("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

Console