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

              
                <div id="left-flyout-nav" class="layout-left-flyout visible-sm"></div>
<div class="layout-right-content">
  <header class="the-header">
    <div class="navbar container">
      
      <!-- Trigger -->
      <a class="btn-navbar btn-navbar-navtoggle btn-flyout-trigger" href="#">
        <span class="icon-bar btn-flyout-trigger"></span>
        <span class="icon-bar btn-flyout-trigger"></span>
        <span class="icon-bar btn-flyout-trigger"></span>
      </a>
      
      <!-- Structure -->
      <nav class="the-nav nav-collapse clearfix">
        <ul class="nav nav-pill pull-left">
          <li class="dropdown">
            <a href="#">Get Info <b class="caret"></b></a>
            <ul class="subnav">
              <li><a href="#">Grad e-list</a></li>
              <li><a href="#">Undergrad e-list</a></li>
              <li><a href="#">Chat Sessions</a></li>
              <li><a href="#">Honor Students</a></li>
              <li><a href="#">Veterans</a></li>
              <li><a href="#">Out of State</a></li>
              <li><a href="#">International</a></li>
              <li><a href="#">DACA</a></li>
              <li><a href="#">About Umass Boston</a></li>
              <li><a href="#">Meet Admissions</a></li>
            </ul>
          </li>
          <li class="dropdown">
            <a href="#">Visit  <b class="caret"></b></a>
            <ul class="subnav">
              <li><a href="#">Tour Sign-up</a></li>
              <li><a href="#">Showcase Saturdays</a></li>
              <li><a href="#">Honors College</a></li>
              <li><a href="#">Nursing Sessions</a></li>
              <li><a href="#">Transfer Student</a></li>
              <li><a href="#">Open House</a></li>
              <li><a href="#">Spring</a></li>
              <li><a href="#">Welcome Day</a></li>
              <li><a href="#">Parent &amp; Family</a></li>
              <li><a href="#">Group</a></li>
              <li><a href="#">Graduate</a></li>
              <li><a href="#">Plan A Visit</a></li>
            </ul>
          </li>
          <li class="dropdown">
            <a href="#">Apply  <b class="caret"></b></a>
            <ul class="subnav">
              <li><a href="#">Freshman</a></li>
              <li><a href="#">Transfer</a></li>
              <li><a href="#">International</a></li>
              <li><a href="#">Graduate</a></li>
              <li><a href="#">Check Status</a></li>
              <li><a href="#">AP/CLEP</a></li>
            </ul>
          </li>
          <li class="dropdown">
            <a href="#">Paying for College  <b class="caret"></b></a>
            <ul class="subnav">
              <li><a href="#">Tuition Fees</a></li>
              <li><a href="#">Work Study</a></li>
              <li><a href="#">Scholarships</a></li>
              <li><a href="#">Financial Aid</a></li>
              <li><a href="#">Questions</a></li>
            </ul>
          </li>
          <li class="dropdown">
            <a href="#">Admitted Students  <b class="caret"></b></a>
            <ul class="subnav">
              <li><a href="#">Checklist</a></li>
              <li><a href="#">Deposit</a></li>
              <li><a href="#">Events</a></li>
              <li><a href="#">Housing &amp; Dining</a></li>
              <li><a href="#">Why Umass Boston</a></li>
            </ul>
          </li>
        </ul>
        <ul class="nav nav-pill pull-right">
          <!-- <li><a href="#">On Campus </a></li> -->
          <li><a href="#">Academics </a></li>
        </ul>
      </nav>
    </div>
  </header>
  
  <main class="container">
    <h1 class="align-center">Responsive Navigation</h1>
    <center><img src="http://dummyimage.com/700x400/ccc/fff" class="hero-image" /></center>
    
    <h3 class="align-center">&rarr; RESIZE THE SCREEN! &larr;</h3>
    
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in lobortis magna, quis pretium dui. Sed laoreet ex ut justo maximus aliquet. Praesent at pulvinar lacus. Aliquam finibus est sapien, interdum lacinia justo vehicula in. Vivamus dignissim odio a risus venenatis, at vestibulum ligula tempor. Curabitur ut porta justo. Aliquam ut porttitor urna. Cras nec rutrum justo. Aliquam iaculis finibus ligula vel tempor.</p>
    
    <p>Nulla posuere libero magna, vel vestibulum sem finibus eget. Nunc dapibus lacus ullamcorper turpis suscipit, sit amet malesuada velit mattis. Nullam id posuere magna. Integer pulvinar, nibh vitae porttitor suscipit, nisi lacus posuere quam, quis sodales diam elit sed lorem. Suspendisse potenti. Pellentesque sodales, quam eu bibendum consectetur, felis arcu egestas libero, quis commodo ligula felis at elit. Suspendisse eu pharetra ex, id vehicula eros. Morbi quis sodales arcu</p>
    
    <br /><br />
  </main>
</div><!-- END .layout-left-flyout -->
              
            
!

CSS

              
                @import "compass/css3";

/* cbFlyNav Req Styles */


body {
  /* These styles don't have to be on body,
     they could be on an element that wraps around
     the left-flyout-nav and the content. 
     This is to prevent a problem on Chrome that
     leaves the width of the container with the 
     added width of the flyout nav even after it's been
     hidden. */
  position: relative;
  overflow-x: hidden;
  width: 100%;
}

.layout-left-flyout {
  height: 100%;
  position: fixed;
  visibility: hidden;
  z-index: 0;
  transition: visibility 0 linear .2s;
  background: #383838;
  -webkit-perspective: 1000;
  -webkit-backface-visibility: hidden;
  -webkit-transform-style: preserve-3d;
}
.layout-left-flyout.isCbFlyNavActive {
  visibility: visible;
  transition: z-index 0 linear .2s;
  z-index: 1;
}

.cbFlyNav-wrap {
  display: block;
  position: relative;
  height: 100%;
  overflow: hidden;
  width: 270px;
  background: #383838;
  -webkit-perspective: 1000;
  -webkit-backface-visibility: hidden;
  -webkit-transform-style: preserve-3d;
  > nav {
    transform: translateY(0);
    transition: transform 0 ease-in-out;
/*    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;*/
  }
}

.nav-collapse {
  -webkit-transform: translate3d(0,0,0);
  -webkit-transform-style: preserve-3d;
}

.layout-right-content {
  transition: transform .2s ease-in-out;
  transform: translate3d(0,0,0);
  -webkit-perspective: 1000;
  -webkit-transform-style: preserve-3d;
  -webkit-backface-visibility: hidden;
  z-index: 1;
  /* NOTE! Put container bg here so you don't
     get any clipping when the content is 
     transitioning. Any tips on alternate 
     solutions are welcome.
  */
  background: #fff;
  background: #f2f2f2;
}
.layout-right-content.isCbFlyNavActive {
  transform: translate3d(270px,0,0);
  min-width: 320px;
}

.icon-cbmore {
  content: "";
  float: right;
  margin-top: 4.5px;
  padding: 4.5px;
  box-shadow: 1px -1px 0 0px #FFF inset;
  -webkit-transform: rotate(225deg);
}

.nav-flyout-navmask, .nav-flyout-contentmask {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.nav-flyout-contentmask {
  z-index: 1;
}
.nav-flyout-navmask {
  right: 180px;
  z-index: 1;
}
/* Menu Toggle */

.btn-navbar {
  position: absolute;
  width: 50px;
  height: 40px;
  padding: 4px 0;
  display: block;
  z-index: 1;
}
.btn-navbar-navtoggle {
  left: 10px;
}
.btn-navbar .icon-bar {
  display: block;
  width: 28px;
  height: 4px;
  background-color: #4d4d4d;
  margin: 7px auto 0 auto;
}
.btn-navbar .icon-bar+.icon-bar {
  margin-top: 3px;
}
@media screen and (min-width: 768px) {
  .btn-navbar {
    display: none;
  }
}

/* Navbar Styles */
.navbar {
  height: 40px;
  margin: 0;
  padding: 5px 0;
  position: relative;
  background: #fafafa;
  margin-bottom: 10px;
  width: 100%;
  padding: 0 10px;
  font-family: 'Open Sans', Arial, Sans-serif;
  box-shadow: 0 1px 1px 0px #dddddd;
  
}
@media screen and (max-width: 767px) {
  .navbar .nav-collapse {
    display: none;
  }
}

@media screen and (min-width: 768px) {
  .navbar {
    height: auto;
    position: relative;
    background: #fafafa;
    margin-bottom: 10px;
    width: 100%;
    padding: 0 10px;
    
  }
}

/* Mobile First Nav */
.the-nav {
  ul.nav-flyout {
    display: block;
    margin-bottom: 15px;
    float: none;
    height: 100%;
    background: #383838;
    > li {
      float: none;
      display: block;
      width: 270px;
    }
    li {
      a {
        color: #FFF;
        display: block;
        text-decoration: none;
        padding: 11px 15px;
        margin-right: 0;
        &:hover {
          background: #cccccc;
          color: #111111;
          & i.icon-cbmore {
            box-shadow: 1px -1px 0 0px #111 inset;
          }
        }
      }
    }
    .dropdown {
      position: static;
      .subnav {
        float: none;
        position: absolute;
        display: block;
        top: 0;
        right: 0;
        left: auto;
        width: 0;
        min-width: 0;
        margin: 0;
        list-style: none;
        z-index: 1000;
        background: #595959;
        transition: width .2s ease-in-out;
        >li {
            width: 180px;
        }
        &.is-subnav-visible {
          width: 180px;
        }
      }
    }
  }
  &.is-inactive ul.nav-flyout{
    > li {
      > a {
        opacity: .2;
      }
      &.is-active > a {
        opacity: 1;
        background: #cccccc;
        color: #22222;
      }
    }
  }
}

/* Large Screen Styles*/ 
@media screen and (min-width: 768px) {
  .container {
    width: 95%;
    margin: 0 auto;
  }
  .the-nav{
    display: block;
  }
  .the-nav .nav{
    display: block;
  }
  .the-nav .nav-pill:after {
    content: "";
    display: table;
    clear: both;
  } 
  .the-nav > .nav {
    margin: 0;
    line-height: normal;
  }
  .the-nav > .nav > li{
    display: inline-block;
    margin-bottom: 0;
    position: relative;
  }
  .the-nav > .nav > li .caret {
    margin-top: 8px;
    margin-left: 2px;
    border-top-color: #A7A7A7;
    border-bottom-color: #A7A7A7;
  }
  .the-nav > .nav > li a{
    display: block;
    padding: 10px 10px 10px;
    color: #222222;
    font-weight: 500;
    text-decoration: none;
  }
  .the-nav > .nav > li:nth-of-type(1) > a{
    padding-left: 0;
  }
  .the-nav > .nav > li:last-of-type > a{
    padding-right: 0;
  }

  /* Active State */ 
  .the-nav > .nav > li:hover > a {
    color: #303030;
  }
  .the-nav > .nav > li:hover .subnav {
    display: block;
  }

  .the-nav > .nav > li:hover .caret {
    border-top-color: #303030;
    border-bottom-color: #303030;
  }

  /* Subnav */ 

  .nav > li > .subnav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    margin: 0;
    padding: 0;
    min-width: 160px;
    background: #F7F7F7;
    box-shadow: 0 1px 1px 0px #DDDDDD;
  }
  .nav > li > .subnav > li{
    margin-bottom: 0;

  }
  .nav > li > .subnav > li a{
    color: #222222;
    transition: all .2s;
  }
  .nav > li > .subnav > li:hover a{
    background: #cccccc;
    color: #111111;
  }
}

/* General Mobile First Styles */ 

.hidden-sm {
  display: none;  
}
@media screen and (min-width: 768px) {
  .visible-sm {
    display: none;
  }
  .hidden-sm {
    display: block;  
  }
}

/* Resets and clean ups and extras */

*, *:before, *:after {
  @include box-sizing(border-box);
}

body {
  background: #f2f2f2;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
  li {
    margin: 0;
  }
}

.pull-left {float: left;}
.pull-right {float: right;}


.dropdown .caret {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: top;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid gray;
  content: "";
}

.clearfix:after {
  content: "";
  display: table;
  clear:both;
}

.container {
  font-family: 'Open Sans', Arial, Sans-serif;
  max-width: 1200px;
  width: 95%;
  margin: 0 auto;
  &.navbar {
    width: 100%;
  }

  &:before, &:after {
    content: "";
    display: table;
    clear: both;
  }
}

h1 {
  font-size: 3.7em;
  font-weight: 200;
  margin-top: .2em;
}
p {
  font-size: 1em;
  line-height: 1.4em;
  font-weight: 400;
}
img.hero-image {
  max-width: 700px;
  width: 100%;
}
.align-center {
  text-align: center;
}
.layout-right-content {
  color: #222222;
}

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,300,300italic,600,600italic,700,700italic,800,800italic);
              
            
!

JS

              
                ;(function ( $, window, document, undefined ) {
  
  $body = $( 'body' );
  
  $.cbFlyNav = function( options, element ) {
		this.$el = $( element );
		this._init( options );
	};
 
  $.cbFlyNav.defaults = {
    trigger: '.btn-flyout-trigger'
    ,cbNavWrapper: '#left-flyout-nav'
    ,cbContentWrapper: '.layout-right-content'
    ,minWidth: 768
	};
  
  $.cbFlyNav.prototype = {
  
    _init : function( options ) {
      this.options = $.extend({}, $.cbFlyNav.defaults, options);
      
      //Cache elements and intit variables
      this._config();
      
      //Initialize event listenters
      this._initEvents();
    },
    
    _config : function() {
			this.open = false;
      this.copied = false;
      this.windowWith = $(window).width();
      this.subNavOpen = false;
      this.wasOpened = false;
      this.$cbWrap = $('<div class="cbFlyNav-wrap"></div>');
      this.$trigger = $(this.options.trigger);
      this.$regMenus = this.$el.children( 'ul.nav.nav-pill' );
      this.$newMenus = $(this.$el.clone());
      this.$contentMask = $('<a class="nav-flyout-contentmask" href="#"></a>');
      this.$navMask = $('<a class="nav-flyout-navmask" href="#"></a>');
      this.$openSubnav = "";
		},
    
    _initEvents : function() {
      var self = this; 
      
      self.$trigger.on('click.cbFlyNav', function(e) {
        e.stopPropagation();
        
        if ( !self.open ) {
          if ( !self.copied ) {
            self._copyNav();
          }
          self._openNav();
        }
        else {
          self._closeNav();
        }
        self.wasOpened = true;
        
        //console.log('WasOpened: '+self.wasOpened+ '. Open? '+self.open);
      });
      
      //Hide menu when window is bigger than allowed minWidth
      $(window).on('resize', function() {
        var windowWidth = $(window).width();
        if(self.open && windowWidth > self.options.minWidth){
          self._closeNav();
        }
      });
      
      //Hide menu when body clicked. Usign an a tag to mask content.
      self.$contentMask.on('click.cbFlyNav', function( e ) {
        e.preventDefault();
        self._closeNav();
      });
      
      self.$navMask.on('click.cbFlyNav', function( e ) {
        e.preventDefault();
        self._closeSubNav();
      });
      
      //Handle clicks inside menu
      self.$newMenus.on( 'click.cbFlyNav', function( e ) {
        e.stopPropagation();
        var $menu = $(this);
        
        //console.log("Menu clicked");
      });
      
      //Handle menu item clicks
      self.$newMenus.children().find('li').on('click.cbFlyNav', function(e) {
        e.stopPropagation();
        var $item = $(this),
            $subnav = $item.find('ul.subnav');
        
        if ($subnav.length > 0) {
          //item with subnav clicked
          
          //console.log("Item with subnav clicked");

          $subnav.css('height', window.innerHeight);
          self._openSubNav($subnav);
        }
        else {
          //item without subnav clicked
          //console.log("Item without subnav clicked");
        }
      });
      
    },
    
    _copyNav : function() {
      var self = this;
      console.log("copying nav");
      
      var newWrap = $('<div class="cbFlyNav-wrap"></div>');
      self.$newMenus.children( 'ul.nav.nav-pill' ).each(function() {
        $this = $(this);
        $this.removeClass('nav-pill').addClass('nav-flyout');
        $this.find('.caret').replaceWith('<i class="icon-cbmore"></i>')
      });
            
      $(self.options.cbNavWrapper).prepend(self.$cbWrap.prepend(self.$newMenus));
      self.copied = true;
     
    },
    
    openNav : function() {
      if ( !this.open ) {
        this._openNav();
      }
    },
    
    _openNav : function() {
      var self = this;
      console.log("Opening Nav");
        
      $(self.options.cbNavWrapper).addClass('isCbFlyNavActive');
      $(self.options.cbContentWrapper)
                        .addClass('isCbFlyNavActive')
                        .append(self.$contentMask);

      self.open = true;
    },
    
    closeNav : function() {
      if ( !this.close ) {
        this._closeNav();
      }
    },
    
    _closeNav : function() {
      var self = this;
      console.log("Closing Nav");
      
      $(self.options.cbNavWrapper).removeClass('isCbFlyNavActive');
      $(self.options.cbContentWrapper).removeClass('isCbFlyNavActive');
      
      if(self.subNavOpen) {
        self._closeSubNav();
      }
      self.$contentMask.detach();

      self.open = false;
    },
    
    _openSubNav : function($subnav) {
      var self = this,
          $parent = $subnav.parent('li');
          
      $subnav.addClass('is-subnav-visible');
      $parent.addClass('is-active');
      self.$newMenus.addClass('is-inactive');
      self.$cbWrap.append(self.$navMask);
      
      $subnav.on('click.cbFlyNav', function(e) {
        e.stopPropagation();
      });
      
      self.$openSubnav = $subnav;
      self.subNavOpen = true;
    },

    _closeSubNav : function() {
      var self = this,
          $parent = self.$openSubnav.parent('li');
      
      self.$openSubnav.removeClass('is-subnav-visible');
      $parent.removeClass('is-active');
      self.$newMenus.removeClass('is-inactive');
      self.$navMask.detach();
      
      self.$openSubnav.off('click.cbFlyNav');
      
      self.$openSubnav = "";
      self.subNavOpen = false;
    }
  };
  
  
  $.fn.cbFlyout = function ( options ) {
    this.each(function() {	
      var instance = $.data( this, 'cbFlyout' );
      if ( instance ) {
        instance._init();
      }
      else {
        instance = $.data( this, 'cbFlyout', new $.cbFlyNav( options, this ) );
      }
    });
    
    return this;
  }
  
}(jQuery, window, document));

$(document).ready(function(){
  $('.the-nav').cbFlyout();
});
              
            
!
999px

Console