Created
September 12, 2012 16:52
-
-
Save skopp/3708062 to your computer and use it in GitHub Desktop.
More content or navigation can be displayed off-canvas above the core content. Pros
- Saves space for core content.
- Elegant Cons
- JS Dependency - Not necessarily a con, but ensure that off-canvas content is still accessible for users with poor/no JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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="http://bradfrost.github.com/this-is-responsive/patterns.html">←More Responsive Patterns</a> | |
</nav> | |
</div> | |
</footer> | |
<!--End Footer--> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 = $('.oc-content').outerHeight(); | |
}); | |
})(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment