-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss-only-responsive-menu.html
221 lines (215 loc) · 4.53 KB
/
css-only-responsive-menu.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<html>
<head>
<title>CSS only responsive menu</title>
<style>
/* A simple, css only, (some-what) responsive menu */
body {
background: #ccc;
font-family: helvetica, arial, serif;
font-size: 13px;
text-transform: uppercase;
text-align: center;
}
a {
outline: none;
}
.wrap {
display: inline-block;
-webkit-box-shadow: 0 0 70px #fff;
-moz-box-shadow: 0 0 70px #fff;
box-shadow: 0 0 70px #fff;
margin-top: 40px;
}
/* a little "umph" */
.decor {
background: #6EAF8D;
background-size: 50px 25%;
padding: 2px;
display: block;
}
a {
text-decoration: none;
color: #fff;
display: block;
}
ul {
list-style: none;
position: relative;
text-align: left;
margin: 0px;
padding: 0px;
}
li {
float: left;
}
/* clear'n floats */
ul:after {
clear: both;
}
ul:before, ul:after {
content: " ";
display: table;
}
nav {
position: relative;
background: #2B2B2B;
background-image: -webkit-linear-gradient(bottom, #2B2B2B 7%, #333333 100%);
background-image: -moz-linear-gradient(bottom, #2B2B2B 7%, #333333 100%);
background-image: -o-linear-gradient(bottom, #2B2B2B 7%, #333333 100%);
background-image: linear-gradient(bottom, #2B2B2B 7%, #333333 100%);
text-align: center;
letter-spacing: 1px;
text-shadow: 1px 1px 1px #0E0E0E;
-webkit-box-shadow: 2px 2px 3px #888;
-moz-box-shadow: 2px 2px 3px #888;
box-shadow: 2px 2px 3px #888;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
}
/* prime */
ul.primary li a {
display: block;
padding: 20px 30px;
border-right: 1px solid #3D3D3D;
}
ul.primary li:last-child a {
border-right: none;
}
ul.primary li a:hover {
color: #000;
}
/* subs */
ul.sub {
position: absolute;
z-index: 200;
box-shadow: 2px 2px 0 #BEBEBE;
width: 35%;
display: none;
padding: 0px;
}
ul.sub li {
float: none;
margin: 0;
}
ul.sub li a {
border-bottom: 1px dotted #ccc;
border-right: none;
color: #000;
padding: 15px 30px;
}
ul.sub li:last-child a {
border-bottom: none;
}
/* sub display*/
ul.primary li:hover ul {
display: block;
background: #fff;
}
/* keeps the tab background white */
ul.primary li:hover a {
background: #fff;
color: #666;
text-shadow: none;
}
ul.primary li:hover > a {
color: #000;
}
ul.primary li:hover ul.sub li a:hover {
color: #000;
background: #eeeeee;
}
@media only screen and (max-width:600px) {
.decor {
padding: 3px;
}
.wrap {
width: 100%;
margin-top: 0px;
}
li {
float: none;
}
ul.primary li:hover a {
background: none;
color: #8B8B8B;
text-shadow: 1px 1px #000;
}
ul.primary li:hover ul {
display: block;
background: #272727;
color: #fff;
}
ul.sub {
display: block;
position: static;
box-shadow: none;
width: 100%;
}
ul.sub li a {
background: #272727;
border: none;
color: #8B8B8B;
}
ul.sub li a:hover {
color: #ccc;
background: none;
}
}
</style>
</head>
<body>
<h1>CSS only responsive menu</h1>
<head>
<meta name="viewport" content="width=device-width">
</head>
<div class="wrap">
<span class="decor"></span>
<nav>
<ul class="primary">
<li>
<a href="">Dog</a>
<ul class="sub">
<li><a href="">Bulldog</a></li>
<li><a href="">Mastiff</a></li>
<li><a href="">Labrador</a></li>
<li><a href="">Mutt</a></li>
</ul>
</li>
<li>
<a href="">Cat</a>
<ul class="sub">
<li><a href="">Tabby</a></li>
<li><a href="">Black Cat</a></li>
<li><a href="">Wrinkly Cat</a></li>
</ul>
</li>
<li>
<a href="">Bird</a>
<ul class="sub">
<li><a href="">Humming Bird</a></li>
<li><a href="">Hawk</a></li>
<li><a href="">Crow</a></li>
</ul>
</li>
<li>
<a href="">Horse</a>
<ul class="sub">
<li><a href="">Brown Horse</a></li>
<li><a href="">Race Horse</a></li>
<li><a href="">Tall Horse</a></li>
</ul>
</li>
<li>
<a href="">Burger</a>
<ul class="sub">
<li><a href="">Cheesy</a></li>
<li><a href="">More Ketchup</a></li>
<li><a href="">Some Mustard</a></li>
<li><a href="">Extra Butter</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</body>
</html>