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

              
                <html>
	<head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script></head>
  <body>
    <div id="menu">
    	<ul>
    		<li><a href="#header">Home</a></li>
    		<li><a href="#first_container">First</a></li>
    		<li><a href="#second_container">Second</a></li>
    	</ul>
    </div>
    <div class="main-content">
      <div id="header" class="content">
        <h1>Home</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum obcaecati perspiciatis, adipisci deleniti modi distinctio, inventore culpa, odit consequatur ipsam cum id! Aperiam consectetur exercitationem, voluptatibus accusamus quidem repellendus aliquid!</p>
      </div>
      <div id="first_container" class="content">
        <h1>First Container</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit eligendi provident minus mollitia minima, totam reiciendis quibusdam porro numquam optio molestias, pariatur et laborum illum enim. Id totam repudiandae doloremque?
        </p>
      </div>
      <div id="second_container" class="content">
        <h1>Second Container</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero nobis obcaecati maiores recusandae quos autem pariatur cum iste vitae repudiandae nostrum labore ex ab voluptas voluptatibus, ut, rerum culpa consectetur.</p>
      </div>
    </div>
  </body>
</html>
              
            
!

CSS

              
                *{padding:0;margin:0;}
body {font-family:sans-serif;}
#menu {position:absolute; width:100%; position:fixed; top:0; left:0; color:#fff; font-weight:bold; text-align:center;}
#menu ul {margin:0; padding:10px; height:30px; list-style:none; background-color:#333}
#menu ul li {display:inline-block;}
#menu ul li a {padding:.5em; text-decoration:none; color:#fff;}

.main-content{padding:50px 0; width:100%;}
.content{min-height:300px; padding:2em;}

#header{background-color:#f06292;}
#first_container{background-color:#ce93d8;}
#second_container{background-color:#dce775;}
              
            
!

JS

              
                $(document).ready(function() {
  // smooth scroll modified by me@nandaabiz.com
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({ scrollTop: (target.offset().top-$('#menu').height()) }, 1000);
        return false;
      }
    }
  });
});
              
            
!
999px

Console