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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <head>
    <!-- FONTS -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800|Open+Sans+Condensed:300|Oxygen" rel="stylesheet">
</head>

<body>
    
    <header id="header">
        <div class="row">
            <h1>HERO</h1>
        </div> 
     
    </header>
    
    <nav class="navbar one-page-nav">
        <nav class="wrapper">
            <div class="logo">Logo</div><!-- Logo -->
        <input type="checkbox" id="menu-toggle">
          <label for="menu-toggle" class="label-toggle"></label>
        </input>
        <ul id="navigation" class="nav">            
          <a href="#services" data-scroll="services"><li>Services</li></a>
          <a href="#about" data-scroll="about"><li>About</li></a>
          <a href="#testimonials" data-scroll="testimonials"><li>Testimonials</li></a>
          <a href="#contact" data-scroll="contact"><li>Contact</li></a>
          <a href="#header"><li class="to-top">To Top</li></a>
        </ul>
        </nav>
    </nav>
    
    <section id="services" data-anchor="services" class="padd">
        <div class="row"><h1 class="text-center">Services</h1></div>
        <div class="row"><p class="lead text-center text-red">Services...</p></div>
    </section>

    
    <section id="divider">Divider</section>

    
    <section id="about" data-anchor="about" class="padd">
        <div class="row"><h1 class="text-center">About</h1></div>
        <div class="row"><p class="lead text-center text-red">About...</p></div>
    </section>

    
    <section id="divider">Divider</section>
    
    <section id="testimonials" data-anchor="testimonials" class="padd">
    	<div class="row"><h1 class="text-center">Testimonials</h1></div>
        <div class="row"><p class="lead text-center text-red">Testimonials...</p></div>
    </section>
    
    <section id="divider">Divider</section>
    
    <section id="contact" data-anchor="contact" class="padd">
        <div class="row"><h1 class="text-center">Contact</h1></div>
        <div class="row"><p class="lead text-center text-red">Contact...</p></div>
    </section>
    
    <footer id="divider">Footer</footer>
    
</body>
              
            
!

CSS

              
                /* General */


body {
    margin: 0;
    background: #fafafa;
}


.row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}


#divider {
    height: 200px;
    background-color: white;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}


/* Typography */

body { 
	font-family: "Open Sans", sans-serif;
	color: #808080; 
	margin: 0; 
	font-size: 1em; 
	font-weight: 300;
}

h1 { 
	font-family: "Oxygen", "Open Sans", sans-serif;
	color: #21252b;
	font-weight: 500;
    font-size: 4em; 
    margin-bottom: 1em;

} 


p { 
	font-family: "Open Sans", sans-serif; 
	font-size: 1.2em; 
	font-weight: 300;
	color: #808080;
}



/* Header */

header {
    height: 500px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}


/* Nav */
.navbar {
  background-color: #fffffb;
  min-width: 100%; 
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  margin-bottom: 2em;
  opacity: 0.96;
  z-index: 9999;
}

.logo {
  display: inline-block;
  height: 50px;
}

.wrapper {
  margin: 0 auto;
  max-width: 100%;
  padding: 0 2%;
}

nav ul{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
    list-style-type: none;
    margin: 0;
    padding: 0;
}
    
nav a {
      color: #21252b;
      text-decoration: none;
}

nav a:hover {
    color: #e63347;
    text-decoration: none;        
}

  
nav li  {
    display: inline-block;
    width: 120px;
    text-align: center;
  }

nav a:hover [class^="fa"] { 
    color: #e63347;
    -webkit-transition: all 0.5s ease-out;
	transition: all 0.5s ease-out; 
}
  
#menu-toggle {display: none;}
  
.label-toggle {display: none;}
  
.wrapper {
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
  }


.to-top {
    text-align: right;
}
  
  @media screen and (max-width: 768px) {
    nav ul {
      background-color: #fffffb;
      display: block;
      height: 0;
      list-style-type: none;
      opacity: 0;
      text-align: left;
      -webkit-transition: all 1s ease;
      transition: all 1s ease;
      width: 100%;
      visibility: hidden;
      -webkit-box-pack: end;
      -ms-flex-pack: end;
      justify-content: flex-end;
      padding: 0;
    }
    
    nav li {
      border-bottom: 1px solid #efefef;
      color: #21252b;
      display: block;
      font-size: 1em;
      width: 100%;
      padding-top: 1em;
      padding-bottom: 1em;
    }
      
    nav li:hover {
        color: #e63347;
        -webkit-transition: all 0.5s ease-out;
	    transition: all 0.5s ease-out;
    }
      
    nav span {
      padding-left: 1em;
    }
      
    .to-top {
      text-align: center;
    }
      
    .logo {
      margin-left: 0.6em;
    }     
    
  
    #menu-toggle:checked ~ ul {
      opacity: 1;
      height: 100%;
      visibility: visible;
    }
    
    .label-toggle {
      background: -webkit-linear-gradient(top, #21252b 0%, #21252b 20%, transparent 20%, transparent 40%, #21252b 40%, #21252b 60%, transparent 60%, transparent 80%, #21252b 80%, #21252b 100%);
      background: linear-gradient(to bottom, #21252b 0%, #21252b 20%, transparent 20%, transparent 40%, #21252b 40%, #21252b 60%, transparent 60%, transparent 80%, #21252b 80%, #21252b 100%);
      cursor: pointer;
      display: block;
      float: right;
      height: 20px;
      margin-top: 1.3em;
      margin-right: 1em;
      width: 20px;
    }
    
    .wrapper {display: block;}

}

/* Services */

#services {
    height: 800px;
    padding-bottom: 80px;
}

.centered {
    margin: 0 auto;
    padding: 0 1em;
}

/* About */

#about {
    height: 800px;
    padding-bottom: 80px;
}



/*Testimonials*/

#testimonials {
    height: 800px;
    padding-bottom: 80px;
}


/* Contact */

#contact {
    height: 1000px;
    padding-bottom: 80px;
}


/* Fixes */

.padd {
    padding-top: 160px;
}

.expand {
    padding-top: 380px;
}
              
            
!

JS

              
                // Sticky Plugin v1.0.0 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 2/14/2011
// Date: 2/12/2012
// Website: http://labs.anthonygarand.com/sticky
// Description: Makes an element on the page stick on the screen as you scroll
//       It will only set the 'top' and 'position' of your element, you
//       might need to adjust the width in some cases.

(function($) {
  var defaults = {
      topSpacing: 0,
      bottomSpacing: 0,
      className: 'is-sticky',
      wrapperClassName: 'sticky-wrapper',
      center: false,
      getWidthFrom: '',
      responsiveWidth: false
    },
    $window = $(window),
    $document = $(document),
    sticked = [],
    windowHeight = $window.height(),
    scroller = function() {
      var scrollTop = $window.scrollTop(),
        documentHeight = $document.height(),
        dwh = documentHeight - windowHeight,
        extra = (scrollTop > dwh) ? dwh - scrollTop : 0;

      for (var i = 0; i < sticked.length; i++) {
        var s = sticked[i],
          elementTop = s.stickyWrapper.offset().top,
          etse = elementTop - s.topSpacing - extra;

        if (scrollTop <= etse) {
          if (s.currentTop !== null) {
            s.stickyElement
              .css('position', '')
              .css('top', '');
            s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className);
            s.currentTop = null;
          }
        }
        else {
          var newTop = documentHeight - s.stickyElement.outerHeight()
            - s.topSpacing - s.bottomSpacing - scrollTop - extra;
          if (newTop < 0) {
            newTop = newTop + s.topSpacing;
          } else {
            newTop = s.topSpacing;
          }
          if (s.currentTop != newTop) {
            s.stickyElement
              .css('position', 'fixed')
              .css('top', newTop);

            if (typeof s.getWidthFrom !== 'undefined') {
              s.stickyElement.css('width', $(s.getWidthFrom).width());
            }

            s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className);
            s.currentTop = newTop;
          }
        }
      }
    },
    resizer = function() {
      windowHeight = $window.height();

      for (var i = 0; i < sticked.length; i++) {
        var s = sticked[i];
        if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) {
          s.stickyElement.css('width', $(s.getWidthFrom).width());
        }
      }
    },
    methods = {
      init: function(options) {
        var o = $.extend({}, defaults, options);
        return this.each(function() {
          var stickyElement = $(this);

          var stickyId = stickyElement.attr('id');
          var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName 
          var wrapper = $('<div></div>')
            .attr('id', stickyId + '-sticky-wrapper')
            .addClass(o.wrapperClassName);
          stickyElement.wrapAll(wrapper);

          if (o.center) {
            stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
          }

          if (stickyElement.css("float") == "right") {
            stickyElement.css({"float":"none"}).parent().css({"float":"right"});
          }

          var stickyWrapper = stickyElement.parent();
          stickyWrapper.css('height', stickyElement.outerHeight());
          sticked.push({
            topSpacing: o.topSpacing,
            bottomSpacing: o.bottomSpacing,
            stickyElement: stickyElement,
            currentTop: null,
            stickyWrapper: stickyWrapper,
            className: o.className,
            getWidthFrom: o.getWidthFrom,
            responsiveWidth: o.responsiveWidth
          });
        });
      },
      update: scroller,
      unstick: function(options) {
        return this.each(function() {
          var unstickyElement = $(this);

          var removeIdx = -1;
          for (var i = 0; i < sticked.length; i++)
          {
            if (sticked[i].stickyElement.get(0) == unstickyElement.get(0))
            {
                removeIdx = i;
            }
          }
          if(removeIdx != -1)
          {
            sticked.splice(removeIdx,1);
            unstickyElement.unwrap();
            unstickyElement.removeAttr('style');
          }
        });
      }
    };

  // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
  if (window.addEventListener) {
    window.addEventListener('scroll', scroller, false);
    window.addEventListener('resize', resizer, false);
  } else if (window.attachEvent) {
    window.attachEvent('onscroll', scroller);
    window.attachEvent('onresize', resizer);
  }

  $.fn.sticky = function(method) {
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error('Method ' + method + ' does not exist on jQuery.sticky');
    }
  };

  $.fn.unstick = function(method) {
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method ) {
      return methods.unstick.apply( this, arguments );
    } else {
      $.error('Method ' + method + ' does not exist on jQuery.sticky');
    }

  };
  $(function() {
    setTimeout(scroller, 0);
  });
})(jQuery);


/**
 * Single Page Nav Plugin
 * Copyright (c) 2013 Chris Wojcik <hello@chriswojcik.net>
 * Dual licensed under MIT and GPL.
 * @author Chris Wojcik
 * @version 1.1.0
 */

// Utility
if (typeof Object.create !== 'function') {
    Object.create = function(obj) {
        function F() {}
        F.prototype = obj;
        return new F();
    };
}

(function($, window, document, undefined) {
    "use strict";
    
    var SinglePageNav = {
        
        init: function(options, container) {
            
            this.options = $.extend({}, $.fn.singlePageNav.defaults, options);
            
            this.container = container;            
            this.$container = $(container);
            this.$links = this.$container.find('a');

            if (this.options.filter !== '') {
                this.$links = this.$links.filter(this.options.filter);
            }

            this.$window = $(window);
            this.$htmlbody = $('html, body');
            
            this.$links.on('click.singlePageNav', $.proxy(this.handleClick, this));

            this.didScroll = false;
            this.checkPosition();
            this.setTimer();
        },

        handleClick: function(e) {
            var self  = this,
                link  = e.currentTarget,
                $elem = $(link.hash);  

            e.preventDefault();             

            if ($elem.length) { // Make sure the target elem exists

                
                // Prevent active link from cycling during the scroll
                self.clearTimer();

                // Before scrolling starts
                if (typeof self.options.beforeStart === 'function') {
                    self.options.beforeStart();
                }

                self.setActiveLink(link.hash);
                
                self.scrollTo($elem, function() { 
                 
                    if (self.options.updateHash) {
                        document.location.hash = link.hash;
                    }

                    self.setTimer();

                    // After scrolling ends
                    if (typeof self.options.onComplete === 'function') {
                        self.options.onComplete();
                    }
                });                            
            }     
        },
        
        scrollTo: function($elem, callback) {
            var self = this;
            var target = self.getCoords($elem).top;
            var called = false;

            self.$htmlbody.stop().animate(
                {scrollTop: target}, 
                { 
                    duration: self.options.speed, 
                    complete: function() {
                        if (typeof callback === 'function' && !called) {
                            callback();
                        }
                        called = true;
                    }
                }
            );
        },
        
        setTimer: function() {
            var self = this;
            
            self.$window.on('scroll.singlePageNav', function() {
                self.didScroll = true;
            });
            
            self.timer = setInterval(function() {
                if (self.didScroll) {
                    self.didScroll = false;
                    self.checkPosition();
                }
            }, 250);
        },        
        
        clearTimer: function() {
            clearInterval(this.timer);
            this.$window.off('scroll.singlePageNav');
            this.didScroll = false;
        },
        
        // Check the scroll position and set the active section
        checkPosition: function() {
            var scrollPos = this.$window.scrollTop();
            var currentSection = this.getCurrentSection(scrollPos);
            this.setActiveLink(currentSection);
        },        
        
        getCoords: function($elem) {
            return {
                top: Math.round($elem.offset().top) - this.options.offset
            };
        },
        
        setActiveLink: function(href) {
            var $activeLink = this.$container.find("a[href='" + href + "']");
            var $parent = $activeLink.parent();
            this.$container.find('.' + this.options.currentClass).removeClass(this.options.currentClass);
			$parent.addClass(this.options.currentClass);
        },        
        
        getCurrentSection: function(scrollPos) {
            var i, hash, coords, section;
            
            for (i = 0; i < this.$links.length; i++) {
                hash = this.$links[i].hash;
                
                if ($(hash).length) {
                    coords = this.getCoords($(hash));
                    
                    if (scrollPos >= coords.top - this.options.threshold) {
                        section = hash;
                    }
                }
            }
            
            // The current section or the first link
            return section || this.$links[0].hash;
        }
    };
    
    $.fn.singlePageNav = function(options) {
        return this.each(function() {
            var singlePageNav = Object.create(SinglePageNav);
            singlePageNav.init(options, this);
        });
    };
    
    $.fn.singlePageNav.defaults = {
        offset: 0,
        threshold: 120,
        speed: 400,
        currentClass: 'current',
        updateHash: false,
        filter: '',
        onComplete: false,
        beforeStart: false
    };
    
})(jQuery, window, document);

//Navscroll
(function($) {
  "use strict";
  $(window).scroll(function() {
    var scrollTop = $(window).scrollTop();
    $(".section").each(function() {
      var elementTop = $(this).offset().top - $('#header').outerHeight();
      if(scrollTop >= elementTop) {
        $(this).addClass('loaded');
      }
    });
  });

  // One Page Navigation Setup
  $('.one-page-nav #navigation').singlePageNav({
    offset: $('.one-page-nav').outerHeight(),
    filter: ':not(.external)',
    speed: 750,
    currentClass: 'active',

    beforeStart: function() {
    },
    onComplete: function() {
    }
  });

		
//sticky menu
	$(".navbar").sticky({topSpacing:0});
    
    
// Padding Fix        
        
    document.getElementById("menu-toggle").addEventListener("click", function(e){

            console.log(e);
            console.log(e.srcElement.classList);
            var theDropDown = document.querySelectorAll(".padd");
            var i;
            var found = false;

            e.srcElement.classList.forEach(function(item) { 
                if(!found && item === 'expand'){
                    for (i = 0; i < theDropDown.length; i++) {
                    theDropDown[i].classList.remove("expand");}
                    found = true;
                }

                if(!found && item === 'padd'){
                    for (i = 0; i < theDropDown.length; i++) {
                    theDropDown[i].classList.add("expand");}
                    found = true;
                }


                console.log(item);
                console.log(e.srcElement.classList);
            });

            if (!found){
                for (i = 0; i < theDropDown.length; i++) {
                theDropDown[i].classList.toggle("expand");}
            }

        });
  
})(jQuery);
              
            
!
999px

Console