Skip to content

Instantly share code, notes, and snippets.

@revitalk
Last active February 3, 2016 04:24
Show Gist options
  • Save revitalk/51ae41edc37d0c675435 to your computer and use it in GitHub Desktop.
Save revitalk/51ae41edc37d0c675435 to your computer and use it in GitHub Desktop.
Basic responsive side menu
*{
padding:0;
margin:0;
}
#wrapper{
padding:1em;
max-width:960px;
margin:0 auto;
}
nav{
width:25%;
float:left;
}
nav li{
padding:5px;
border-bottom:1px solid black;
list-style-type: none;
}
#menu-toggle{
display:none;
}
.content{
width:70%;
float:right;
}
@media (max-width: 480px) {
#menu-toggle{
display:block;
}
.close{
display:none;
}
.open{
display:block;
/* if you want the menu to lay on top of the content add the following:
position:absolute;
width:50%;
background-color: #fff;*/
}
.content{
float:none;
width:90%;
}
nav{
float:none;
width:90%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1">
<title>Web Page Title</title>
<link rel="stylesheet" href="basic-side-menu.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#menu-toggle').click(function () {
$('#menu').toggleClass('open');
e.preventDefault();
});
});
</script>
</head>
<body>
<div id="wrapper">
<nav>
<button id="menu-toggle">menu</button>
<ul id="menu" class="close">
<li><a href="#">link1</a></li>
<li><a href="#">link2</a></li>
<li><a href="#">link3</a></li>
<li><a href="#">link4</a></li>
<li><a href="#">link5</a></li>
</ul>
</nav>
<div class="content">
<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>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment