Instantly share code, notes, and snippets.
Last active
August 29, 2015 14:17
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save armornick/47c15fef5226baeca3b3 to your computer and use it in GitHub Desktop.
First responsive navigation test from scratch
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>Manual Nesponsive Ravigation</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; } | |
/* clearfix: https://css-tricks.com/snippets/css/clear-fix/ */ | |
.cfx:after { content: ""; display: table; clear: both; } | |
header[role='banner'] { background-color: #ddd; } | |
header[role='banner'] h1 { text-align: center; } | |
nav[role='navigation'] { text-align: center; } | |
nav[role='navigation'] li { list-style: none; margin-left: 0; } | |
nav[role='navigation'] a { display: block; text-decoration: none; color: inherit; padding: 0.5em 0; } | |
.nav-collapse { display: none; } | |
.nav-toggle { margin-left: 75%; text-decoration: none; } | |
.wrap { max-width: 1140px; margin-left: auto; margin-right: auto; padding: 0.6em; } | |
.box { float: left; } | |
@media only screen and (min-width: 40em) { | |
nav[role='navigation'] { display: block; } | |
nav[role='navigation'] li { display: inline-block; } | |
nav[role='navigation'] a { display: inline; margin-left: 2em; } | |
.nav-toggle { display: none; } | |
.box { width: 33%; padding: 2%; } | |
} | |
@media only screen and (min-width: 60em) { | |
header[role='banner'] h1 { float: left; margin-left: 1em; } | |
nav[role='navigation'] { display: block; float: right; margin-right: 10em; margin-top: 2em; } | |
.box { width: 25%; padding: 1%; } | |
} | |
</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> | |
<header class="cfx" role="banner"> | |
<h1>Nesponsive Ravigation</h1> | |
<a href="#" class="nav-toggle" data-toggle-navbar="navbar">Menu</a> | |
<nav id="navbar" class="nav-collapse" role="navigation"> | |
<li><a href="#">Link</a></li> | |
<li><a href="#">Link</a></li> | |
<li><a href="#">Link</a></li> | |
<li><a href="#">Link</a></li> | |
</nav> | |
</header> | |
<div class="wrap"> | |
<main role="main"> | |
<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> | |
<section id="grid" class="cfx"> | |
<article class="box"> | |
<h2>Grid Item</h2> | |
<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> | |
</article> | |
<article class="box"> | |
<h2>Grid Item</h2> | |
<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> | |
</article> | |
<article class="box"> | |
<h2>Grid Item</h2> | |
<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> | |
</article> | |
<article class="box"> | |
<h2>Grid Item</h2> | |
<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> | |
</article> | |
<article class="box"> | |
<h2>Grid Item</h2> | |
<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> | |
</article> | |
</section> | |
<footer role="contentinfo"> | |
<small>Copyright © <time datetime="2015">2015</time></small> | |
</footer> | |
</div> | |
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
// responsive navigation menu | |
$('.nav-toggle').click(function () { | |
var id = $(this).attr('data-toggle-navbar'); | |
$('#'+id).toggleClass('nav-collapse'); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment