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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <nav>
    <a href="#page01">LINK 1</a>
    <a href="#page02">LINK 2</a>
    <a href="#page03">LINK 3</a>
    <a href="#page04">LINK 4</a>
  </nav>

    <article>
      <section id="page01" class="section">
        <h1>LINK 1</h1>
        <div></div>
        <div></div>
      </section>
      <section id="page02" class="section">
        <h1>LINK 2</h1>
        <div></div>
      </section>
      <section id="page03" class="section">
        <h1>LINK 3</h1>
        <div></div>
        <div></div>
      </section>
      <section id="page04" class="section">
        <h1>LINK 4</h1>
        <div></div>
        <div></div>
        <div></div>
      </section>
    </article>
              
            
!

CSS

              
                nav {
    position: fixed;
    top: 50%;
    right: 50px;
    z-index: 10;
    transform: translate(0, -50%);
  }
  nav a {
    display: block;
    margin: 30px 10px;
    width: 10px;
    height: 10px;
    background: #000;
    border-radius: 50%;
    font-size: 0;
    text-decoration: none;
  }
  nav a.active {
    background: #fff;
  }
  h1 {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 10;
    transform: translate(-50%, -50%);
    font-size: 50px;
  }
  .section {
    position: relative;
    z-index: 1;
  }
  .section div {height: 300px;}
  #page01 {
    background: orange;
  }
  #page02 {
    background: pink;
  }
  #page03 {
    background: skyblue;
  }
  #page04 {
    background: grey;
  }
              
            
!

JS

              
                const controller = new ScrollMagic.Controller(); // 1. ScrollMagic 컨트롤러 생성
      const section = document.querySelectorAll('.section');

      section.forEach( (el, index) => {
        const id = el.getAttribute('id');
        const height = el.clientHeight; // 2. 컨텐츠별 높이값 설정
        new ScrollMagic.Scene({triggerElement: `#${id}`, duration: height, triggerHook: 0}) // 3. 뷰포트 지점(0, OnLeave) 설정
					.setClassToggle(`nav a:nth-child(${index+1})`, "active") // 4. 페이지 네비게이션의 활성화 클래스 추가
					.addIndicators()
          .addTo(controller);
      });
      // 5. controller의 scrollTo 이벤트에 따른 부드럽게 이동하는 TweenMax 효과 추가
      controller.scrollTo(function (newpos) {
        TweenMax.to(window, 0.5, {scrollTo: {y: newpos}}); 
      });

      const nav = document.querySelectorAll('nav a');
      
      nav.forEach( (el) => {
        // 6. 네비게이션 클릭 시 해당 href값에 따른 scrollTo 이벤트 발생
        el.addEventListener('click', (e) => {
          const id = e.target.getAttribute('href');
          if (document.querySelector(id)) {
            e.preventDefault();
            controller.scrollTo(id);
          }
        })
      })
              
            
!
999px

Console