Here is example to make Simple and Nice Navbar with Dropdown Menu Using jQuqery
Fire structure:
Jquery-Dropdown/
┣ css/
┃ ┗ style.css
┣ js/
┃ ┗ main.js
┗ index.php
index.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="js/main.js" type="text/javascript"></script>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<nav>
<header>
<ul class="left-nav">
<li><a href="#">Logo</a></li>
</ul>
<ul class="right-nav">
<li class="dropdown">
<div style="margin-bottom: 10px;">
<a href="" id="services">Services</a>
</div>
<ul class="sub-menu">
<li><a href="#">Android Development</a></li>
<li><a href="#">Web development</a></li>
<li><a href="#">Graphics Design</a></li>
<li><a href="#">Training</a></li>
</ul>
</li>
<li><a href="">Portfolio</a></li>
<li class="chat"><a href="#" class="minimize-chat">Live Chat</a></li>
</ul>
</header>
</nav>
</body>
</html>
style.css
body{
margin: 0;
padding: 0;
background: #ebe8e8;
}
nav header{
background: #928c8c;
height: 65px;
}
nav header > ul{
margin: 0;
}
nav header > ul > li{
margin-top: 20px;
}
ul.right-nav{
float: right;
}
nav li a{
text-decoration: none;
font-family:sans-serif;
text-transform: uppercase;
font-weight: 100;
color: #fff;
font-size: 14px;
}
nav li{
list-style-type: none;
float: left;
margin-right: 10px;
}
ul.sub-menu {
position: absolute;
width: 200px;
padding: 10px 0px 10px 10px;
background: #fff;
display: none;
padding-top: 10px;
padding-bottom: 10px;
box-shadow:0.1px 0.1px 10px rgba(0, 0, 0, 0.1);
border-radius: 2px;
}
ul.sub-menu li:first-child{
margin-top: -20px;
}
ul.sub-menu li{
margin-bottom: 35px;
position: relative;
}
ul.sub-menu li > a:hover{
border:none;
color: #ff9900;
}
ul.sub-menu li a{
color: #000;
text-decoration: none;
}
.sub-menu:before{
width: 16px;
height: 16px;
background-size: 100%;
background-repeat: no-repeat;
content: " ";
display: inline-block;
position: relative;
top: -15px;
left: 5px;
z-index: 0;
border-left: 10px solid #fff;
border-bottom: 10px solid #fff;
transform: rotate(133deg);
margin-right: 7px;
transition: none;
}
main.js
$(document).ready(function () {
$('.dropdown').hover(function () {
$(this).children('.sub-menu').slideDown(200);
},
function () {
$(this).children('.sub-menu').slideUp(200);
}
);
});
Download source code
Are you facing problems in understanding this article? download source code now