Skip to content

Instantly share code, notes, and snippets.

@monecchi
Created March 8, 2014 00:56
Show Gist options
  • Save monecchi/9423391 to your computer and use it in GitHub Desktop.
Save monecchi/9423391 to your computer and use it in GitHub Desktop.
Respond Tutorial by Mat Helme on TreeHouse Blog:
/**
* Respond Tutorial by Mat Helme on TreeHouse Blog:
* http://blog.teamtreehouse.com/create-an-absolute-basic-mobile-css-responsive-navigation-menu
*/
/*RESET*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background:transparent;} body {line-height: 1;}ol, ul{list-style:none;} blockquote, q{quotes:none;} blockquote:before, blockquote:after, q:before, q:after{content:'';content:none;} :focus{outline:0;} ins{text-decoration:none;} del{text-decoration:line-through;} table{border-collapse:collapse; border-spacing:0;}
/*MAIN*/
body {
font-size: 1.05em;
line-height: 1.25em;
font-family: Helvetica Neue, Helvetica, Arial;
background: #f9f9f9;
color: #555;
}
a {
color: #4C9CF1;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #444;
}
img {
width: 100%;
}
header {
background: #fff;
width: 100%;
height: 76px;
position: fixed;
top: 0;
left: 0;
border-bottom: 4px solid #4C9CF1;
z-index: 100;
}
#logo{
margin: 20px;
float: left;
width: 200px;
height: 40px;
background: url('http://treehouse-blog.s3.amazonaws.com/Respond-Menu/img/logo.png') no-repeat center;
display: block;
}
nav {
float: right;
padding: 20px;
}
#menu-icon {
display: hidden;
width: 40px;
height: 40px;
background: #4C8FEC url('http://treehouse-blog.s3.amazonaws.com/Respond-Menu/img/menu-icon.png') center;
}
a:hover#menu-icon {
background-color: #444;
border-radius: 4px 4px 0 0;
}
ul {
list-style: none;
}
li {
display: inline-block;
float: left;
padding: 10px
}
.current {
color: #2262AD;
}
section {
margin: 80px auto 40px;
max-width: 980px;
position: relative;
padding: 20px
}
h1 {
font-size: 2em;
color: #2262AD;
line-height: 1.15em;
margin: 20px 0 ;
}
p {
line-height: 1.45em;
margin-bottom: 20px;
}
/*MEDIA QUERY*/
@media only screen and (max-width : 640px) {
header {
position: absolute;
}
#menu-icon {
display:inline-block;
}
nav ul, nav:active ul {
display: none;
position: absolute;
padding: 20px;
background: #fff;
border: 5px solid #444;
right: 20px;
top: 60px;
width: 50%;
border-radius: 4px 0 4px 4px;
}
nav li {
text-align: center;
width: 100%;
padding: 10px 0;
margin: 0;
}
nav:hover ul {
display: block;
}
}
<html lang="en">
<head>
<meta charset="utf-8">
<title>Responsive Header Nav</title>
<meta name="description" content="Responsive Header Nav">
<meta name="author" content="Treehouse">
<meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1">
<!-- <link rel="stylesheet" href="css/styles.css"> -->
<!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<header>
<a href="#" id="logo"></a>
<nav>
<a href="#" id="menu-icon"></a>
<ul>
<li><a href="#" class="current">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Work</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<section>
<div class="topbanner">
</div>
<img src="http://treehouse-blog.s3.amazonaws.com/Respond-Menu/img/featured.png" alt="Respond" />
<h1>Respond to Your Surroundings</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam interdum gravida velit, non elementum sem scelerisque condimentum. Aliquam scelerisque lectus in fringilla luctus. Pellentesque cursus orci non elit viverra, in dapibus eros tempor. Sed quis velit nec felis dapibus pulvinar convallis nec velit. Donec eget odio facilisis, ultrices mi ac, dapibus nibh. Phasellus ut quam ullamcorper, mattis tortor rhoncus, venenatis elit. Integer a commodo velit. Sed condimentum sed tortor at venenatis. Nunc cursus mollis ligula et volutpat. Aenean tincidunt augue vel pulvinar mollis. Donec sagittis hendrerit orci, a fermentum lectus tincidunt non. Nullam auctor venenatis aliquam. Vivamus elementum, eros quis volutpat pharetra, quam ipsum consectetur nisl, id placerat neque mi vitae est.</p>
<h1>Respond to Your Surroundings</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam interdum gravida velit, non elementum sem scelerisque condimentum. Aliquam scelerisque lectus in fringilla luctus. Pellentesque cursus orci non elit viverra, in dapibus eros tempor. Sed quis velit nec felis dapibus pulvinar convallis nec velit. Donec eget odio facilisis, ultrices mi ac, dapibus nibh. Phasellus ut quam ullamcorper, mattis tortor rhoncus, venenatis elit. Integer a commodo velit. Sed condimentum sed tortor at venenatis. Nunc cursus mollis ligula et volutpat. Aenean tincidunt augue vel pulvinar mollis. Donec sagittis hendrerit orci, a fermentum lectus tincidunt non. Nullam auctor venenatis aliquam. Vivamus elementum, eros quis volutpat pharetra, quam ipsum consectetur nisl, id placerat neque mi vitae est.</p>
</section>
</body>
</html>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"80","seethrough":"","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment