This jQuery based plain css drop down menu is very simple illustration that you don’t need any dramatic coding to achieve simple 2 level menu.
Css drop down menus are based only on cascading style sheet functionality, but on some old not A grade browsers they lack some features.
In this example i used very simple jQuery plugin which helps me with “mouse over” event, and adds/removes some class from some elements.
So take it, use it, recommend it if you like it!
Example of this menu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Webtoolkit.info jQuery menu</title>
<style type="text/css">
#navigation {
font-family: georgia;
font-size: 18px;
padding: 0px;
margin: 0px;
list-style-type: none;
}
#navigation li {
position: relative;
float: left;
margin: 0px 1px 0px 0px;
}
#navigation li a {
display: block;
padding: 5px 35px;
-moz-border-radius-topleft: 5px;
-webkit-border-top-left-radius: 5px;
-moz-border-radius-topright: 5px;
-webkit-border-top-left-right: 5px;
background: #cc0000;
color: #ffffff;
text-decoration: none;
}
#navigation li ul {
position: absolute;
left: 0px;
top: 0px;
display: none;
padding: 0px;
margin: 0px;
list-style-type: none;
}
#navigation li.over {
top: 1px;
}
#navigation li.over a {
background: #009bcc;
}
#navigation li.over ul {
padding: 5px!important;
display: block;
background: #009bcc;
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-left-right: 5px;
-moz-border-radius-topright: 5px;
-webkit-border-bottom-top-right: 5px;
}
#navigation li.over ul li {
float: none;
margin: 0px!important;
top: 0px;
}
#navigation li.over ul li a {
font-size: 14px;
padding: 3px 30px;
background: none;
white-space: nowrap;
}
#navigation li.over ul li a:hover {
background: #00bbf7;
color: #000000;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.extend({
//plugin name - animatemenu
webtoolkitMenu: function(options) {
return this.each(function() {
//Assign current element to variable, in this case is UL element
var obj = $(this);
$("li ul", obj).each(function(i) {
$(this).css('top', $(this).parent().outerHeight());
})
$("li", obj).hover(
function () { $(this).addClass('over'); },
function () { $(this).removeClass('over'); }
);
});
}
});
})(jQuery);
$(document).ready(function() {
$('#navigation').webtoolkitMenu();
});
</script>
</head>
<body>
<ul id="navigation"><!--
--><li><a href="">Sign up</a></li><!--
--><li><a href="">Orders</a><!--
--><ul><!--
--><li><a href="">Dashboard</a></li><!--
--><li><a href="">Order list</a></li><!--
--></ul><!--
--></li><!--
--><li><a href=""><span><span>My account</span></span></a><!--
--><ul><!--
--><li><a href="">Dashboard</a></li><!--
--><li><a href="">Profile</a></li><!--
--><li><a href="">Change password</a></li><!--
--></ul><!--
--></li><!--
--></ul>
</body>
</html>
|