Menu responsive jquery sederhana

by dafin defandaky

HTML

<nav class="reso-db">
		<ul class="reso-db">
			<li><a href="#">Beranda</a></li>
			<li><a href="#">About</a></li>
			<li><a href="#">Kontak</a></li>
			<li><a href="#">Label</a></li>
			<li><a href="#">Isi</a></li>
			<li><a href="#">Alat</a></li>	
		</ul>
		<a href="#" id="db-pull">Menu</a>
	</nav>

CSS

/* Clearfix */
.reso-db:before,
.reso-db:after {
    content: " ";
    display: table;
}
.reso-db:after {
    clear: both;
}
.reso-db {
    *zoom: 1;
}

/* Basic Styles */
body {
	background-color: #ece8e5;
}
nav {
	height: 40px;
	width: 100%;
	background: #363;
	font-size: 11pt;
	font-family: 'PT Sans', Arial, sans-serif;
	font-weight: bold;
	position: relative;
	border-bottom: 2px solid #292929;
}
nav ul {
	padding: 0;
	margin: 0 auto;
	width: 600px;
	height: 40px;
}
nav li {
	display: inline;
	float: left;
}
nav a {
	color: #fff;
	display: inline-block;
	width: 100px;
	text-align: center;
	text-decoration: none;
	line-height: 40px;
	text-shadow: 1px 1px 0px #283744;
}
nav li a {
	border-right: 1px solid #399;
	box-sizing:border-box;
	-moz-box-sizing:border-box;
	-webkit-box-sizing:border-box;
}
nav li:last-child a {
	border-right: 0;
}
nav a:hover, nav a:active {
	background-color: #8c99a4;
}
nav a#db-pull {
	display: none;
}

/*Styles for screen 600px and lower*/
@media screen and (max-width: 600px) {
	nav { 
  		height: auto;
  	}
  	nav ul {
  		width: 100%;
  		display: block;
  		height: auto;
  	}
  	nav li {
  		width: 50%;
  		float: left;
  		position: relative;
  	}
  	nav li a {
		border-bottom: 1px solid #399;
		border-right: 1px solid #399;
	}
  	nav a {
	  	text-align: left;
	  	width: 100%;
	  	text-indent: 25px;
  	}
}

/*Styles for screen 515px and lower*/
@media only screen and (max-width : 480px) {
	nav {
		border-bottom: 0;
	}
	nav ul {
		display: none;
		height: auto;
	}
	nav a#db-pull {
		display: block;
		background-color: #283744;
		width: 100%;
		position: relative;
	}
	nav a#db-pull:after {
		content:"";
		background: url('http://1.bp.blogspot.com/-YbCOkgZJu9M/VL2WleBciQI/AAAAAAAACjA/Y_voN2AEgBI/s1600/nav-icon.png') no-repeat;
		width: 30px;
		height: 30px;
		display: inline-block;
		position: absolute;
		right: 15px;
		top: 10px;
	}
}

/*Smartphone*/
@media only screen and (max-width : 320px) {
	nav li {
		display: block;
		float:...

JavaScript

$(function() {
			var pull 		= $('#db-pull');
				menu 		= $('nav ul');
				menuHeight	= menu.height();

			$(pull).on('click', function(e) {
				e.preventDefault();
				menu.slideToggle();
			});

			$(window).resize(function(){
        		var w = $(window).width();
        		if(w > 320 && menu.is(':hidden')) {
        			menu.removeAttr('style');
        		}
    		});
		});