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 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

              
                
<!-- Use class "smooth-scrollbar" to enable smooth scrollbar 
============================================================ -->
<div id="body-inner" class="smooth-scrollbar">

  <nav id="nav" class="nav-fixed">
    <ul>
      <li><a href="#section-1" class="sm-scroll">Section 1</a></li>
      <li><a href="#section-2" class="sm-scroll">Section 2</a></li>
      <li><a href="#section-3" class="sm-scroll">Section 3</a></li>
    </ul>
  </nav>

  <div id="scroll-container">
    <div id="content-wrap">
    
      <div id="hero">
        <h1>Hero</h1>
      </div>
      
      <div id="section-1" class="section">
        <h2>Section 1</h2>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam consectetur fuga nam eligendi placeat natus consequuntur ab ea tenetur odit, minima, vel. Eaque accusantium atque molestias praesentium. Dolorem dolores dolor nobis obcaecati, iure officiis ipsa pariatur quibusdam sint placeat non soluta eius tempore quis, in saepe natus sit debitis, laboriosam voluptatibus iusto laborum ratione. Officiis adipisci neque illum, repellat cupiditate dolores nam ducimus itaque voluptatum maiores, sed a voluptates rerum temporibus quo at ipsa facilis suscipit non. Quasi quisquam est facilis eaque explicabo a commodi esse blanditiis impedit consectetur dolores repellendus error culpa libero ab molestias, quis eos laudantium voluptatem!
      </div> <!-- /.section -->
      
      <div id="section-2" class="section">
        <h2>Section 2</h2>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam consectetur fuga nam eligendi placeat natus consequuntur ab ea tenetur odit, minima, vel. Eaque accusantium atque molestias praesentium. Dolorem dolores dolor nobis obcaecati, iure officiis ipsa pariatur quibusdam sint placeat non soluta eius tempore quis, in saepe natus sit debitis, laboriosam voluptatibus iusto laborum ratione. Officiis adipisci neque illum, repellat cupiditate dolores nam ducimus itaque voluptatum maiores, sed a voluptates rerum temporibus quo at ipsa facilis suscipit non. Quasi quisquam est facilis eaque explicabo a commodi esse blanditiis impedit consectetur dolores repellendus error culpa libero ab molestias, quis eos laudantium voluptatem!
      </div> <!-- /.section -->
      
      <div id="section-3" class="section">
        <h2>Section 3</h2>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam consectetur fuga nam eligendi placeat natus consequuntur ab ea tenetur odit, minima, vel. Eaque accusantium atque molestias praesentium. Dolorem dolores dolor nobis obcaecati, iure officiis ipsa pariatur quibusdam sint placeat non soluta eius tempore quis, in saepe natus sit debitis, laboriosam voluptatibus iusto laborum ratione. Officiis adipisci neque illum, repellat cupiditate dolores nam ducimus itaque voluptatum maiores, sed a voluptates rerum temporibus quo at ipsa facilis suscipit non. Quasi quisquam est facilis eaque explicabo a commodi esse blanditiis impedit consectetur dolores repellendus error culpa libero ab molestias, quis eos laudantium voluptatem!
      </div> <!-- /.section -->
      
    </div> <!-- /#content-wrap -->
  </div> <!-- /#scroll-container -->
  
  <div id="footer">
    <a href="#" class="scroll-to-top">Back to Top</a>
  </div>
      
</div> <!-- /#body-inner -->
              
            
!

CSS

              
                body {
  margin: 0;
  height: 100%;
}


/* Nav */
#nav { 
  position: relative;
	width: 100%;
  background-color: #222;
  z-index: 99998;
}
#nav.nav-fixed { 
  position: fixed;
	top: 0;
	left: 0;
}
#nav ul { 
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
	margin: 0;
  padding: 0;
  list-style: none;
}
#nav ul li { 
  margin: 0 10px;
}
#nav ul li a { 
  color: #FFF;
}

/* Hero */
#hero { 
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: #000;
  color: #fff;
}

/* Scroll container */
#scroll-container { 
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}

/* Section */
.section { 
  height: 100vh;
	padding: 40px;
}
#section-1 { 
	background-color: #da6f6f;
}
#section-2 { 
	background-color: #daad6f;
}
#section-3 { 
	background-color: #dad56f;
}

/* Footer */
#footer { 
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  background-color: #222;
}
#footer a { 
  color: #FFF;
}

/* Scrollbar */
.scrollbar-track {
	z-index: 99999 !important;
}

              
            
!

JS

              
                if ($("#body-inner").hasClass("smooth-scrollbar")) {

  // Smooth Scrollbar plugin: https://idiotwu.github.io/smooth-scrollbar/
  var Scrollbar = window.Scrollbar;
  Scrollbar.init(document.querySelector("#scroll-container"), {
    damping: 0.05,
    renderByPixel: true,
    continuousScrolling: true,
    alwaysShowTracks: true
  });

}


// Smooth scroll between elements.
$('.sm-scroll').on("click", function() {

		var target = this.hash;

		// If fixed header position enabled.
		if ($("#nav").hasClass("nav-fixed")) {
			var $offset = $("#nav").height();
		} else {
			var $offset = 0;
		}

		// You can use data attribute (data-offset="100") to set top offset in HTML markup if needed. 
		if ($(this).data("offset") != undefined) $offset = $(this).data("offset");

		if ($("#body-inner").hasClass("smooth-scrollbar")) {
      var topY = $(target).offset().top - $('#scroll-container > .scroll-content').offset().top - $offset;
      var $scrollbar = Scrollbar.init(document.getElementById("scroll-container"));
      
			gsap.to($scrollbar, { duration: 2, scrollTo: { y: topY, autoKill: true }, ease: Expo.easeInOut });
      
		} else {
			var topY = $(target).offset().top - $('body').offset().top - $offset;
			gsap.to($(window), { duration: 2, scrollTo: { y: topY, autoKill: true }, ease: Expo.easeInOut });
		}
		return false;
});


// Scroll to top.
 $(".scroll-to-top").on("click", function() {
		if ($("#body-inner").hasClass("smooth-scrollbar")) {
			var $scrollbar = Scrollbar.init(document.getElementById("scroll-container"));
			gsap.to($scrollbar, { duration: 2, scrollTo: { y: 0, autoKill: true }, ease: Expo.easeInOut });
		} else {
			gsap.to($(window), { duration: 2, scrollTo: { y: 0, autoKill: true }, ease: Expo.easeInOut });
		}
		return false;
}); 
              
            
!
999px

Console