Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created April 25, 2013 06:41
Show Gist options
  • Save rodrigo-x/5457945 to your computer and use it in GitHub Desktop.
Save rodrigo-x/5457945 to your computer and use it in GitHub Desktop.
helping the indian guy..
.dropdown {
color: #555;
margin: 3px -22px 0 0;
width: 143px;
position: relative;
height: 17px;
text-align: left;
}
.submenu {
background: #fff;
position: absolute;
top: -12px;
left: -20px;
z-index: 100;
width: 135px;
display: none;
margin-left: 10px;
padding: 40px 0 5px;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.dropdown li a {
color: #555555;
display: block;
font-family: arial;
font-weight: bold;
padding: 6px 15px;
cursor: pointer;
text-decoration: none;
}
.dropdown li a:hover {
background: #155FB0;
color: #FFFFFF;
text-decoration: none;
}
a.account {
font-size: 11px;
line-height: 16px;
color: #555;
position: absolute;
z-index: 110;
display: block;
padding: 11px 0 0 20px;
height: 28px;
width: 121px;
margin: -11px 0 0 -10px;
text-decoration: none;
background: url(http://demos.9lessons.info/DropMenu/icons/arrow.png) 116px 17px no-repeat;
cursor: pointer;
}
.root {
list-style: none;
margin: 0px;
padding: 0px;
font-size: 11px;
padding: 11px 0 0 0px;
border-top: 1px solid #dedede;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div class="dropdown">
<a class="account">My Account</a>
<div class="submenu">
<ul class="root">
<li><a href="#Dashboard">Dashboard</a></li>
<li><a href="#Profile">Profile</a></li>
<li><a href="#settings">Settings</a></li>
<li><a href="#feedback">Send Feedback</a></li>
</ul>
</div>
</div>
</body>
</html>
var Menu = (function () {
var account = $(".account"),
submenu = $(".submenu");
account.on("click", function () {
var account_id = account.attr('id');
if (account_id === 1) {
submenu.hide();
account.attr('id', '0');
} else {
submenu.show();
account.attr('id', '1');
}
});
submenu.mouseup(function () {
return false;
});
account.mouseup(function () {
return false;
});
$(document).mouseup(function () {
submenu.hide();
account.attr('id', '');
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment