Pen Settings



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


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


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.


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.


                <body data-spy="scroll" data-target="#navbar-1" data-offset="50">
  <nav id="navbar-1" class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        <a class="navbar-brand" href="#">Brand</a>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="navbar-collapse-1">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#section-start">Start</a></li>
          <li><a href="#section-green">Green</a></li>
          <li><a href="#section-blue">Blue</a></li>
          <li><a href="#section-red">Red</a></li>
          <li><a href="#section-stop">Stop</a></li>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->

  <div id="section-start"><h2>Please wait for a few seconds</h2></div>
  <div id="section-green"><h2>Green</h2></div>
  <div id="section-blue"><h2>Blue</h2></div>
  <div id="section-red"><h2>Red</h2></div>
  <div id="section-stop"><h2><a href="#">Press to stop the loop</a></h2></div>


                @import url('');

body {
  padding-top: 50px;

#section-stop {
  height: 800px;
  padding: 10px 20px;

#section-green { background: #9c6; color: #cf9; }
#section-blue  { background: #69c; color: #9cf; }
#section-red   { background: #c69; color: #f9c; }


                // **** AutoScroll + ScrollSpy ****
var CORRECTION = 50;  // height of the navbar 
// don't forget to setup the data-offset attribute of the <body> tag

var DELAY_READING = 4000; // 4 seconds = 4000; 10 seconds = 10000

var links = [ '#section-start', '#section-green', '#section-blue', '#section-red', '#section-stop' ];
var timerId = 0;


$( '#section-stop a' ).click(function(event) { 

$( '#navbar-1 li a' ).click(function(event) {
  scrollToLink( $(this).attr('href') );

function delayLinks( i ) {
  if( i >= links.length ) i = 0;
  scrollToLink( links[i] );
  var next = ( i == links.length - 1 ? 0 : i + 1);
  timerId = setTimeout(function() { delayLinks( next ) }, DELAY_READING ); 

function scrollToLink( link ) {
  selectLink = $( link );
  if ( selectLink.length ) {
    var top = selectLink.offset().top - CORRECTION;
    $('body,html').stop().animate({scrollTop: top}, DELAY_SCROLLING);
  } else {
    colnsole.log('The link is not found: ' + link);