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

              
                <ul>
  <li><a href="#Link-1" class="fp-nav">Link 1</a></li>
  <li><a href="#Link-2" class="fp-nav">Link 2</a></li>
  <li><a href="#Link-3" class="fp-nav">Link 3</a></li>
  <li><a href="#Link-4" class="fp-nav">Link 4</a></li>
  <li><a href="#Link-5" class="fp-nav">Link 5</a></li>
</ul>

<p><a href="#previous" class="fp-previous">Previous</a></p>

<p><a href="#next" class="fp-next">Next</a></p>

<div class="fp-container">

  <section id="Link-1" class="fp-content">

    <h1>Section #1</h1>

  </section>

  <section id="Link-2" class="fp-content">

    <h1>Section #2</h1>

  </section>

  <section id="Link-3" class="fp-content">

    <h1>Section #3</h1>

  </section>

  <section id="Link-4" class="fp-content">

    <h1>Section #4</h1>

  </section>

  <section id="Link-5" class="fp-content">

    <h1>Section #5</h1>

  </section>

</div>
<!-- .fp-container -->
              
            
!

CSS

              
                // Fading pages requires JavaScript
// Without, it will revert back to default Framework styling
// Use jQuery or JavaScript to add class `.has-js` to body,
// if this fails, the page will still be usable

.has-js {
  .fp-container {
    position: relative;
    z-index: 2;
  }
  .fp-content {
    position: relative;
    top: 0;
    left: 0;
    z-index: 1;
    &.is-off {
      display: none;
      z-index: -1;
    }
    @media only screen and (max-width: 40em) {
      position: relative;
      top: auto;
      left: auto;
      z-index: auto;
      &.is-off {
        display: inherit !important;
        z-index: auto;
      }
    }
  }
}
              
            
!

JS

              
                /*
Fading Pages module plugin for ASUS Framework

This plugin is used meant to be used as AJAX page-wide navigation where history
needs to be retained. More than one fading pages system cannot be installed on the
same page due to this.

This plugin requires JavaScript, jQuery 1.0+
*/

var fadingPages = {};

(function() {

  fadingPages.defaults = function() {

    var _fadingPagesContainer = '.fp-container',
      _fadingPagesContentItem = '.fp-content',
      _fadingPagesNavItem = '.fp-nav',
      _fadingPagesNavPrevious = '.fp-previous',
      _fadingPagesNavNext = '.fp-next',
      _animationOutSpeed = 100,
      _animationInSpeed = 500;

    return {

      fpContainer: function() {
        return _fadingPagesContainer;
      },

      fpContentItem: function() {
        return _fadingPagesContentItem;
      },

      fpNavItem: function() {
        return _fadingPagesNavItem;
      },

      fpNavPrevious: function() {
        return _fadingPagesNavPrevious;
      },

      fpNavNext: function() {
        return _fadingPagesNavNext;
      },

      fpNavArray: function() {

        // Build an array of each nav item's href value
        var navHashList = $(_fadingPagesNavItem).map(function() {
          return $(this).attr('href');
        }).toArray();

        return navHashList;

      },

      fpAnimationOut: function() {
        return _animationOutSpeed;
      },

      fpAnimationIn: function() {
        return _animationInSpeed;
      },

      fpAnimationTotal: function() {
        return _animationOutSpeed + _animationInSpeed;
      }

    };

  };

  // Store the current hash here
  fadingPages.currentID = '';
  // Store the next hash here
  fadingPages.nextID = '';
  // Store the previous hash here
  fadingPages.previousID = '';

  fadingPages.toggleNavState = function(defaults) {

    var ID = this.currentID,
      fpNavItem = defaults.fpNavItem();

    // remove active class from current menu item
    $(fpNavItem + '.is-active').removeClass('is-active');

    // add active class to menu item with current ID
    $('a[href="' + ID + '"]' + fpNavItem).addClass('is-active');

  };

  fadingPages.toggleFadeState = function(element) {

    // Setting on and off classes. We remove the style attribute so
    // it can be overwritten elsewhere
    $(element).toggleClass('is-on is-off').removeAttr('style');

  };

  fadingPages.setPreviousNext = function(defaults) {

    var previous = defaults.fpNavPrevious(),
      next = defaults.fpNavNext();

    // This sets the href attribute for the Previous and Next links if they exist

    if ($(previous).length) {
      $(previous).attr('href', this.previousID);
    }

    if ($(next).length) {
      $(next).attr('href', this.nextID);
    }

  };

  fadingPages.fadeElements = function(defaults) {

    var fadeOutSpeed = defaults.fpAnimationOut(),
      fadeInSpeed = defaults.fpAnimationIn(),
      fpContentItem = defaults.fpContentItem(),
      ID = this.currentID;

    // Fade out currently on content item
    $(fpContentItem + '.is-on').fadeOut(fadeOutSpeed, function() {

      // Toggle classes appropriately on currently on content item
      fadingPages.toggleFadeState($(this));

      // Fade in current ID
      $(ID).fadeIn(fadeInSpeed, function() {

        // toggle classes on new content item
        fadingPages.toggleFadeState($(this));

      });

    });

  };

  fadingPages.hashChange = function(hash, defaults, startup) {

    // If it's not set, make it false
    startup = typeof startup !== 'undefined' ? startup : false;

    var navArray = defaults.fpNavArray(),
      fpContentItem = defaults.fpContentItem();

    // if the hash given is in our navigation array
    if (navArray.indexOf(hash) !== -1) {

      // Only perform update if the hash is different 
      // from the current ID
      if (hash !== this.currentID) {

        // Set the current ID to our new hash
        this.currentID = hash;

        // Set the previous to the last item if we're at the first
        if ($(hash).prev().length > 0) {
          this.previousID = '#' + $(hash).prev().attr('id');
        } else {
          this.previousID = '#' + $(fpContentItem + ':last').attr('id');
        }

        // Set the next item to the first item if we're at the last
        if ($(hash).next().length > 0) {
          this.nextID = '#' + $(hash).next().attr('id');
        } else {
          this.nextID = '#' + $(fpContentItem + ':first').attr('id');
        }

        // Updates active classes for our nav items
        this.toggleNavState(defaults);

        if (!startup) {
          // Fades things in and out if it's not a startup
          this.fadeElements(defaults);
        }

        // After the total fading time, set up the previous / next hrefs
        setTimeout(function() {
          fadingPages.setPreviousNext(defaults);
        }, defaults.fpAnimationTotal());

      }

    } else {

      var firstContentItemID = '#' + $(fpContentItem + ':first').attr('id');

      // if it's not inside the array, default to the first one
      $(firstContentItemID).toggleClass('is-off is-on');
      this.hashChange(firstContentItemID, defaults);

    }

  };

  fadingPages.startUp = function(defaults) {

    var defaults = new fadingPages.defaults(),
      initialHash = window.location.hash;

    $(defaults.fpContentItem()).addClass('is-off');

    if (initialHash.length > 0) {

      $(initialHash).toggleClass('is-off is-on');

      // If we have a hash, load that one
      this.hashChange(initialHash, defaults, true);

    } else {

      var firstContentItemID = '#' + $(defaults.fpContentItem() + ':first').attr('id');

      $(firstContentItemID).toggleClass('is-off is-on');

      this.hashChange(firstContentItemID, defaults, true);

    }

    if (document.addEventListener) {
      window.addEventListener('hashchange', function() {
        fadingPages.hashChange(window.location.hash, defaults);
      });
    } else {
      document.attachEvent('hashchange', function() {
        fadingPages.hashChange(window.location.hash, defaults);
      });
    }

  };

})();

$(document).ready(function() {

  $('body').addClass('has-js');

  fadingPages.startUp();

});
              
            
!
999px

Console