Last active
August 29, 2015 14:17
-
-
Save armornick/20bb70ec048b3ca679ea to your computer and use it in GitHub Desktop.
My first manual off-canvas menu test from scratch (and ongoing testing)
This file contains 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
<!DOCTYPE html> | |
<!-- | |
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit | |
of the public at large and to the detriment of our heirs and | |
successors. We intend this dedication to be an overt act of | |
relinquishment in perpetuity of all present and future rights to this | |
software under copyright law. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
OTHER DEALINGS IN THE SOFTWARE. | |
For more information, please refer to <http://unlicense.org/> | |
--> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Off-Canvas Test</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.2/normalize.min.css" rel="stylesheet" media="all"> | |
<style type="text/css"> | |
html { box-sizing: border-box; } | |
*, *:before, *:after { box-sizing: inherit; } | |
h1, h2, h3, h4, h5, h6 { font-family: serif; } | |
.nav-toggle { position: fixed; top: 5%; right: 5%; } | |
/* still has graphical glitches when resizing from big to small breakpoint... */ | |
#off-canvas { transition: all 1s ease-in-out; } | |
#off-canvas { background-color: #222; color: #eee; height: 100vh; padding: 1em; width: 60%; } | |
#off-canvas > * { color: inherit; } | |
#off-canvas > nav[role='navigation'] > a { display: block; margin-left: 3em; color: inherit; text-decoration: none; } | |
#off-canvas { position: fixed; top: 0; left: 0; margin-left: -60%; } | |
#off-canvas.active { left: 60%; } | |
header[role='banner'] { background-color: #ddd; text-align: center; padding: 1em 0; } | |
.wrap { padding: 1em; } | |
footer[role='contentinfo'] { background-color: #bbb; padding: 1em; } | |
@media only screen and (min-width: 40em) { | |
#off-canvas { transition: none; } | |
.nav-toggle { display: none; } | |
#off-canvas { position: relative; display: inline-block; width: 19%; color: inherit; background-color: inherit; margin: 0; height: auto; vertical-align: top; } | |
.wrap { display: inline-block; width: 79%; margin: 0; } | |
} | |
@media print { | |
.nav-toggle { display: none; } | |
#off-canvas { display: none; } | |
} | |
</style> | |
<!--[if lt IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv-printshiv.min.js" media="all"></script><![endif]--> | |
</head> | |
<body> | |
<button class="nav-toggle" data-target-nav="off-canvas">MENU</button> | |
<div id="page-wrapper"> | |
<header role="banner"> | |
<h1>Main Title</h1> | |
</header> | |
<div class="wrap"> | |
<main role="main"> | |
<h1>Page Title</h1> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo | |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse | |
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non | |
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo | |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse | |
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non | |
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | |
</main> | |
</div> | |
<aside id="off-canvas"> | |
<h1>Sidebar</h1> | |
<nav role="navigation"> | |
<a href="#">Link</a> | |
<a href="#">Link</a> | |
<a href="#">Link</a> | |
<a href="#">Link</a> | |
</nav> | |
</aside> | |
<footer role="contentinfo"> | |
<small>Copyright © <time datetime="2015">2015</time></small> | |
</footer> | |
<script src='https://code.jquery.com/jquery-1.11.2.min.js'></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
$('.nav-toggle').click(function () { | |
var id = $(this).attr('data-target-nav'); | |
$('#'+id).toggleClass('active'); | |
}) | |
}); | |
</script> | |
<div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment