Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <header>
<h1>Vertical Scroll</h1>
</header>
    <ul class="scroll-control"></ul>
    <div class="scroll-el">
      <div class="container">
         <h2>C/ 1</h2>
      </div>
    </div>
    <div class="scroll-el">
      <div class="container">
         <h2>C/ 2</h2>
      </div>
    </div>
    <div class="scroll-el">
      <div class="container">
         <h2>C/ 3</h2>
      </div>
    </div>
    <div class="scroll-el">
      <div class="container">
         <h2>C/ 4</h2>
      </div>
    </div>
    <div class="scroll-el">
     <div class="container">
         <h2>C/ 5</h2>
      </div>
    </div>
    <div class="scroll-el">
      <div class="container">
         <h2>C/ 6</h2>
      </div>
    </div>
    <footer>
      <div class="container">
        <small>Hey there! :]</small>
      </div>
    </footer>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700,300);
* {
  /*transition: all 0.3s;*/
}

:root {
  font-family: 'Source Code Pro';
  font-size: 15px;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: white;
}

h1 {
  margin: 0;
  font-size: 40px;
  text-transform:uppercase;
}

h1:before {
  content: '['
}

h1:after {
  content: ']'
}

h1:before,
h1:after {
  color: SteelBlue;
  font-size: 50px
}


header{
  text-align:center;
  padding:120px 0;
}

.scroll-control{
  position: fixed;
  left: 0;
  top:50%;
  font-size: 0;
  transform: translateY(-50%);
  padding:0px 5px;
}
.scroll-control li{margin: 10px 0;}

.scroll-control a:link, .scroll-control a:visited{
  display: block;
  width: 10px;
  height: 10px;
  background-color: WhiteSmoke;
  transition: all .3s;
}

.scroll-control a:hover, .scroll-control a:active{
  background-color: LightSteelBlue ;
}

.scroll-el{
  min-height: 400px;
  background-color: SteelBlue;
  margin: 0 auto;
  border-bottom: 5px solid SandyBrown;
  padding: 15px;

}

.scroll-selected{
  background-color: SandyBrown !important;
  width:30px !important;
  transform:translateX(10px);
  transition: all .3s;
}

.scroll-el h2{
  text-transform: uppercase;
  color: WhiteSmoke;
  font-size: 40px;
}

footer{
  background-color: WhiteSmoke;
}

.container {
  max-width: 1170px;
  margin: 0 auto;
  padding:20px;
}

footer .container{padding:90px 15px;}

@media (max-width:800px){

  .scroll-control{display: none;}

}
              
            
!

JS

              
                $(function(){

  var $scrollSections = $('.scroll-el');
  var $scrollControl = $('.scroll-control');

  // per ogni sezione assegno un id e inserisco un link con un ancora nella navigazione
  $scrollSections.each(function(i){
    var nEl = i + 1;
    $(this).attr('id', 's' + nEl);
    var listItem = '<li><a class="scroll-link" href="#s' + nEl + '"></a></li>' ;
    $scrollControl.append(listItem);

  });

  // controllo in che sezione sto scrollando
  $(window).on('scroll', function(){

    if( $(window).scrollTop() < $scrollSections.eq(0).offset().top){
      // se sono piu in alto della prima sezione rimuovo la selezione dai bullet
      $scrollControl.find('a').removeClass('scroll-selected');

    }else if( $(window).scrollTop() == $(document).height()-$(window).height() ){
      // se sono alla fine della pagina seleziono l'ultimo bullet
      $scrollControl.find('a').removeClass('scroll-selected');
      $scrollControl.find('li').last().find('a').addClass('scroll-selected');

    }else{
      // per ogni sezione applico la selezione al bullet corrispondente
      $scrollSections.each(function(i){
        if( $(window).scrollTop() >= $(this).offset().top && $(window).scrollTop() <= ( $(this).offset().top + $(this).innerHeight() ) ){
  			 $scrollControl.find('a').removeClass('scroll-selected');
         $scrollControl.find('li').eq(i).find('a').addClass('scroll-selected');
  		  }
      });

    }

  });

  // intercetto la sezione
  $(".scroll-link").on('click', function(e) {
     e.preventDefault();
     var dest;
     if( $(this.hash).offset().top > $(document).height()-$(window).height() ){
          dest = $(document).height()-$(window).height();
     }else{
          dest = $(this.hash).offset().top + 1;
     }
     //scrolla alla sezione
     $('html, body').animate({scrollTop:dest}, 1000,'swing');
  });

});

              
            
!
999px

Console