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

              
                <!-- #Start Pattern -->
<header class="header header--fixed" role="banner">
  <!-- Logo -->
  <h1 class="logo"><a href="#logo">Logo</a></h1>
  
  <!-- Menu Trigger -->
  <a href="#menu" id="menu-trigger"><span aria-hidden="true">Menu</span></a>

  <!-- Nav -->
  <nav id="menu" class="navigation off-canvas--hide" aria-hidden="false" role="navigation">
    <span class="menu-close" aria-hidden="true">X</span>
    <a href="https://bradfrost.github.com/this-is-responsive" class="navigation__link">Features</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">Pricing</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">About</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">Blog</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">Contact</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">Sign In</a>
    <a href="https://bradfrost.github.com/this-is-responsive/patterns.html" class="navigation__link">Sign Up</a>
  </nav>
</header>
<!-- #End Pattern -->

<main role="main">
  <header>
      <h1>The Rest of the Story</h1>
  </header>

  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</main>

	<div class="container">	
		<section class="pattern-description">
			<h1>Off Canvas Full Screen Overlay</h1>
      <p>An off-canvas layout that tucks a top level navigation outside the viewport for small screens but exposes it once enough screen space becomes available.</p>
			<h2>Resources</h2>
			<ul>
			<li><a href="http://www.lukew.com/ff/entry.asp?1517">Off Canvas Multi-Device Layout Entry 1517</a></li>
			<li><a href="http://www.lukew.com/ff/entry.asp?1569">Off Canvas Multi-Device Layouts Entry 1519</a></li>
			<li><a href="http://jasonweaver.name/lab/offcanvas/">Off-Canvas demo by Jason Weaver</a></li>
			<li><a href="https://www.zurb.com/playground/off-canvas-layouts">Off Canvas Layouts in Zurb Foundation</a></li>
			</ul>
		</section>
		<footer role="contentinfo">   
			<div>
				<nav id="menu">
					<a href="https://bradfrost.github.com/this-is-responsive/patterns.html">&larr;More Responsive Patterns</a>
				</nav>
			</div>
		</footer>
	</div>
              
            
!

CSS

              
                /*
 *******************************************************
 * Off Canvas Notes
 * You will need to provide your own fallbacks for any
 * device/browser the does not support transitions and
 * transforms. I would suggest using the right or left
 * property as a fallback to the transforms used.
 *******************************************************
 */


/*
 *******************************************************
 * GLobals
 *******************************************************
 */

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

a {
  color: gray;
}


/*
 *******************************************************
 * Container
 *******************************************************
 */

[role="banner"],
[role="main"] {
  padding: 0 5%;
}

.container {
  width: 100%;
  background: #EFEFEF;
  padding: .5rem 5%; /* 8/16 = .5rem */
}


/*
 *******************************************************
 * Logo
 *******************************************************
 */

.logo {
  font-size: 1.375rem; /* 22/16 = .5rem */
}


/*
 *******************************************************
 * Menu Triggers
 *******************************************************
 */

/* Hide Triggers When JS is Disabled */
.menu-close,
#menu-trigger{
  display: none;
}

.js .menu-close {
  display: inline-block;
  background: #070606;
  color: #F3E8E8;
  padding: .625rem; /* 10/16 = .625rem */
  width: 100%;
  text-align: center;
}


/*
 *******************************************************
 * Media Query Small Screens
 *******************************************************
 */

@media screen and (max-width: 40em) { /* 640/16 = 40em */
  .header {
    padding: 0 5%;
  }

  .js .logo {
    background: #383636;
    position: fixed;
    width: 100%;
    left: 0;
    top: 0;
    margin: 0;
    padding: 1.25rem 5%; /* 8/16 = .5em */
  }

  .js #menu-trigger {
    display: inline-block;
    position: absolute;
    top: 1.375rem; /* 22/16 = .5rem */
    right: 5%;
    color: white;
  }

  #menu-trigger:hover {
    cursor: pointer;
  }

  .js .navigation {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    /* Off Canvas Menu Slide in Speed */
    -webkit-transition: 0.3s -webkit-transform cubic-bezier(0,0,.58,1);
    -moz-transition: 0.3s -moz-transform cubic-bezier(0,0,.58,1);
    -o-transition: 0.3s -o-transform cubic-bezier(0,0,.58,1);
    transition: 0.3s transform cubic-bezier(0,0,.58,1);
    width: 100%;
    overflow-y: auto;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.98);
  }

  /* Hide : Off Canvas Menu */
  .js .off-canvas--hide {
    -webkit-transform: translateX(100%);
    -moz-transform: translateX(100%);
    -ms-transform: translateX(100%);
    -o-transform: translateX(100%);
    transform: translateX(100%);
  }

  /* Show : Off Canvas Menu Class */
  .js .off-canvas--show {
    -webkit-transform: translateX(0);
    -moz-transform: translateX(0);
    -ms-transform: translateX(0);
    -o-transform: translateX(0);
    transform: translateX(0);
  }

  .navigation__link {
    display: block;
    text-align: center;
    padding-left: 1.25rem; /* 20/16 = 1.25rem */
    padding: 0.625rem 1.25rem; /* 10/16 = 0.625rem */ /* 20/16 = 1.25rem */
  }

  .js .header--fixed {
    position: fixed;
    top: 0;
    left: 0;
    /* Layer Promotion for Hardware Acceleration */
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
    width: 100%;
    z-index: 9000; /* because we dont know what is on the page and layered so setting this high pushes our menu to the front of the stack when it slides over our content. */
    height: 100%;
  }

  .js [role="main"] {
    padding-top: 5rem; /* 80/16 = 5rem */
  }
}


@media screen and (max-width: 40.00625em) { /* 640.1/16 = 40.00625em */
  .menu-close:hover {
    cursor: pointer;
  }
}


/*
 *******************************************************
 * Media Query Large Screens
 *******************************************************
 */

@media screen and (min-width: 40.00625em) { /* 640.1/16 = 40.00625em */
  .js .menu-close {
    display: none;
  }

  .js #menu-trigger {
    display: none;
  }

  .navigation {
    display: inline-block;
    width: 100%;
  }
}

              
            
!

JS

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

$('#menu-trigger').on('click', function(e) {
    e.preventDefault();
    $('.navigation').toggleClass('off-canvas--hide off-canvas--show');
    $('.navigation').attr('aria-hidden', 'false');
});

$('.menu-close').on('click', function() {
    $('.navigation').toggleClass('off-canvas--hide off-canvas--show');
    $('.navigation').attr('aria-hidden', 'true');
});

$(window).resize(function() {
  if($(window).width() > 640) {
    $('.navigation').removeClass('off-canvas--show');
    $('.navigation').attr('aria-hidden', 'false');
  } else {
    $('.navigation').addClass('off-canvas--hide');
    $('.navigation').attr('aria-hidden', 'true');
  }
});
              
            
!
999px

Console