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

              
                <body>
    <nav class="main-nav">
        <ul>
            <li><a id="page-link1" href="#page1">One and Two</a></li>
            <li><a id="page-link2" href="#page3">Three and Four</a></li>
            <li><a id="page-link3" href="#page5">Five and Six</a></li>
        </ul>
    </nav>
    <div class="col col-l">
        <div id="page1" class="full-page page1">
            <div class="page-content">Page 1</div>
        </div>
        <div id="page3" class="full-page page2">
            <div class="page-content">Page 3</div>
        </div>
        <div id="page5" class="full-page page2">
            <div class="page-content">Page 5</div>
        </div>
    </div>
    <div class="mask">
        <div class="col col-r">
            <div id="page6" class="full-page page3">
                <div class="page-content">Page 6</div>
            </div>
            <div id="page4" class="full-page page4">
                <div class="page-content">Page 4</div>
            </div>
            <div id="page2" class="full-page page2">
                <div class="page-content">Page 2</div>
            </div>
        </div>
    </div>
</body>
              
            
!

CSS

              
                @import "compass/css3";

body {
 font-family: tahoma, sans-serif;
}
.main-nav {
  position: fixed;
  top: 0;
  width: 100%;
  height: 30px;
  background: rgba(0,0,0,.5);
  text-align: center;
  color: #fff;
  z-index: 1;
}
.main-nav li {
  display: inline-block;
}
.main-nav a:link,
.main-nav a:visited {
  display: inline-block;
  padding: 5px 10px;
  color: #fff;
  text-decoration: none;
  transition: color .3s;
}
.main-nav a:hover,
.main-nav a:active {
  color: #ccc;
}
.col-l {
  float: left;
  width: 50%;
  background-color: #1c7491;
  color: #333;
  text-shadow: 1px 1px 1px rgba(255,255,255,.3);
}
.col-r {
  float: right;
  width: 100%;
  background-color: #214c63;
  overflow: hidden;
  color: #ccc;
  text-shadow: -1px -1px 1px rgba(0,0,0,.9);
}
.full-page {
  box-sizing: border-box;
  width: 100%;
  border: 2px solid rgba(0,0,0,.2);
  font-size: 20px;
  font-weight: bold;
}
.mask {
  position: fixed;
  top: 0;
  right: 0;
  left: 50%;
  bottom: 0;
  overflow: hidden; 
}
.page-content {
  padding: 50px;
  box-sizing: border-box;
}
              
            
!

JS

              
                jQuery(document).ready(function($) {

    //set up scroll to behavior for anchor links
    var scrollControl = {
        scrollElement : $('html, body'),
        anchorLink : $("a[href^='#']"),
        speed : 700,
        //move fluidly to the anchor selected
        moveTo : function(){
            this.anchorLink.click(function(event) {
                //act abnormal
                event.preventDefault();
                //cache and capture some things
                var target = this.hash,
                $target = $(target);
                //set up the actual animation
                scrollControl.scrollElement.stop().animate({
                    'scrollTop': $target.offset().top
                //when it's over, set the has for the url
                }, this.speed, 'swing', function() {
                    window.location.hash = target;
                });
            });
        },
        //stop all motion if the user interacts during motion
        stopMove : function(){
            this.scrollElement.bind('scroll mousedown wheel DOMMouseScroll mousewheel keyup', function(e){
                if ( e.which > 0 || e.type == 'mousedown' || e.type == 'mousewheel'){
                    scrollControl.scrollElement.stop();
                }
            });
        },
        //set everything up
        init : function(){
            this.moveTo();
            this.stopMove();
        }
    };
    //initialize anchor link behavior
    scrollControl.init();

    //set up the half-and-half page scrolling behavior
    var halfHalf = {
        //cache and initialize some variables
        win : $(window),
        colL : $('.col-l'),
        colR : $('.col-r'),
        pages : $('.full-page'),
        curPage : 1,
        pageH : null,
        //get the window's height on demand
        getWinH : function(){
            return this.win.height();
        },
        //set up the negative margin for the inverse scrolling page
        setScroll : function(){
            var revScroll = Math.round(-this.colL.height() + this.win.scrollTop() + this.getWinH());
            this.colR.css('margin-top', revScroll);
        },
        //force the size of the pages to be the window's size
        setSize : function(){
            this.pages.each(function(){
                thisPage = $(this);
                thisPage.height(halfHalf.getWinH());
                halfHalf.pageH = thisPage.height();
            });
        },
        //snap back to a full page if idol for too long
        snapTimer : function() {
            clearTimeout($.data(this, 'scrollTimer'));
            $.data(this, 'scrollTimer', setTimeout(function() {
                $('#page-link' + halfHalf.curPage).click();
            }, 1000));
        },
        //set things up initially
        init : function(){
            //set the initial size and placement of things
            this.setSize();
            this.setScroll();
            //bind these behaviors to various browser interactions
            this.win.resize(function(){
                halfHalf.setSize();
                halfHalf.snapTimer();
            });
            this.win.scroll(function(){
                halfHalf.setScroll();
                halfHalf.snapTimer();
                //the current page is based on the percentage scrolled through the entire site
                halfHalf.curPage = Math.round(halfHalf.win.scrollTop() / halfHalf.pageH) + 1;
            });
        }
    };
    //kick it all off
    halfHalf.init();

});
              
            
!
999px

Console