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="pattern" class="pattern">
    <div class="offcanvas-top">
  		<div class="o-content">
				<p>Here is more content. This could be related items, navigation or other content you feel is conducive to this type of treatment.</p>
				<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean quis nisi et dui placerat ornare. Maecenas molestie lacus lobortis libero lacinia sed scelerisque lectus congue. Mauris dignissim nisi a ante laoreet et ullamcorper ligula ullamcorper. In hac habitasse platea dictumst. In nisi odio, tempor in viverra vitae, mollis ac tortor. Sed a rhoncus leo. Maecenas ac dui elit, tristique dapibus nisl. Suspendisse feugiat porta ligula, auctor posuere lorem vulputate et.</p>
				</div>
		</div>
</div>
	<!--End Pattern HTML-->
<div class="container">	
		<!--Pattern Description-->
		<section class="pattern-description">
			<h1>Off-Canvas Top</h1>
			<p>More content or navigation can be displayed off-canvas above the core content. </p>
			<h2>Pros</h2>
			<ul>
				<li>Saves space for core content.</li>
				<li>Elegant</li>
			</ul>
			<h2>Cons</h2>
			<ul>
				<li><strong>JS Dependency</strong> - Not necessarily a con, but ensure that off-canvas content is still accessible for users with poor/no JS support</li>
				<li><strong>Animation Performance</strong> - Platforms, especially mobile platforms, vary greatly in how well they treat animations. Keep this in mind.</li>
			</ul>
			<h2>Resources</h2>
			<ul>
				<li><a href="http://www.lukew.com/ff/entry.asp?1517">Off Canvas Multi-Device Layout</a></li>
				<li><a href="http://www.lukew.com/ff/entry.asp?1569">Off Canvas Multi-Device Layouts</a></li>
				<li><a href="http://jasonweaver.name/lab/offcanvas/">Off-Canvas demo by Jason Weaver</a></li>
			</ul>
		</section>
		<!--End Pattern Description-->
		
		<!--Footer-->
		<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>
		<!--End Footer-->
	</div>

              
            
!

CSS

              
                .offcanvas-top {
  position: relative;
  overflow: hidden;
  height: 3.2em;
  -webkit-transition: height 0.5s ease-out; 
  -moz-transition: height 0.5s ease-out;  
  -o-transition: height 0.5s ease-out; 
  transition: height 0.5s ease-out;
}
.offcanvas-top.active {
  height: 13.6em;
}
.o-content {
  width: 100%;
  position: absolute;
  bottom: 0;
  padding: 1em 1em 2.5em;
  
}
.crumbs li a {
  display: block;
  padding: 1em;
  border-bottom: 1px solid #000;
}
.crumbs li:last-child a {
  border-bottom: 0;
}
#trigger {
  position: absolute;
  bottom: 0;
  right: 0;
  display: block;
  font-size: 1em; 
  padding: 0 1em 1em;
}
              
            
!

JS

              
                (function(w){
      var $container = $('.offcanvas-top'),
				$cHeight = $('.o-content').outerHeight();
			$(document).ready(function() {
				buildCanvas();
			});
			
			function buildCanvas() {
				$('<a href="#" id="trigger">More +</a>').appendTo($container);

				$('#trigger').bind('click', function(e) {
					e.preventDefault();
					var $this = $(this);
					$container.toggleClass('active');
					if($container.hasClass('active')) {
						$container.height($cHeight);
						$this.text('Hide -');
					} else {
						$container.height(50);
						$this.text('More +');
					}
				});

			}
			
			$(window).resize(function() { //On Window resizeBy(
				$cHeight = $('.o-content').outerHeight();
        console.log($cHeight);
			});
			
			
		})(this);
              
            
!
999px

Console