-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnav.html
More file actions
227 lines (211 loc) · 8.08 KB
/
nav.html
File metadata and controls
227 lines (211 loc) · 8.08 KB
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
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>µCSS — Nav</title>
<link rel="stylesheet" href="../dist/mu.css">
</head>
<body>
<main class="container">
<hgroup>
<h1>Nav</h1>
<p>Horizontal navigation bar — brand, links, buttons, dropdown, vertical. All navbars collapse into a ☰ burger menu on mobile (< 640px).</p>
</hgroup>
<p><a href="index.html">← Back to examples</a></p>
<p><button class="btn btn-sm btn-secondary" onclick="document.documentElement.dataset.theme = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'">Toggle dark mode</button></p>
<section>
<h2>Basic</h2>
<p>Brand on the left, links on the right. <code>.active</code> bolds the current page. Resize the window to see the burger.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-basic" class="navbar-toggle" hidden>
<label for="nav-basic" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#" class="active">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</section>
<section>
<h2>Contrast links</h2>
<p>Using <code>.contrast</code> on links for stronger visibility.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-contrast" class="navbar-toggle" hidden>
<label for="nav-contrast" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#" class="contrast">Home</a></li>
<li><a href="#" class="contrast">About</a></li>
<li><a href="#" class="contrast">Contact</a></li>
</ul>
</nav>
</section>
<section>
<h2>Secondary links</h2>
<p>Using <code>.secondary</code> on links for lighter styling.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-secondary" class="navbar-toggle" hidden>
<label for="nav-secondary" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#" class="secondary">Home</a></li>
<li><a href="#" class="secondary">About</a></li>
<li><a href="#" class="secondary">Services</a></li>
<li><a href="#" class="secondary">Contact</a></li>
</ul>
</nav>
</section>
<section>
<h2>With buttons</h2>
<p>Mixing links and buttons in the navigation.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-buttons" class="navbar-toggle" hidden>
<label for="nav-buttons" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Docs</a></li>
<li><a href="#" role="button">Sign up</a></li>
</ul>
</nav>
</section>
<section>
<h2>With dropdown</h2>
<p>Integrating a <code><details class="dropdown"></code> inside the nav.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-dropdown" class="navbar-toggle" hidden>
<label for="nav-dropdown" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li>
<details class="dropdown">
<summary>More</summary>
<ul>
<li><a href="#">Settings</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Logout</a></li>
</ul>
</details>
</li>
</ul>
</nav>
</section>
<section>
<h2>Vertical (aside)</h2>
<p>Stacked navigation inside an <code><aside></code>.</p>
<aside style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<nav>
<ul>
<li><a href="#">Dashboard</a></li>
<li><a href="#">Users</a></li>
<li><a href="#" class="secondary">Settings</a></li>
<li><a href="#" class="secondary">Help</a></li>
</ul>
</nav>
</aside>
</section>
<section>
<h2>Colored navbars</h2>
<p>Use <code>.bg-{role}</code> for the background — a gradient is applied and text/links switch to inverse color. Works on <code><nav></code> or on a parent <code><header></code>.</p>
<nav class="bg-primary" style="border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Primary</strong></li>
</ul>
<input type="checkbox" id="nav-primary" class="navbar-toggle" hidden>
<label for="nav-primary" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<br>
<nav class="bg-contrast" style="border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Contrast</strong></li>
</ul>
<input type="checkbox" id="nav-contrast-bg" class="navbar-toggle" hidden>
<label for="nav-contrast-bg" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<br>
<nav class="bg-accent" style="border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Accent</strong></li>
</ul>
<input type="checkbox" id="nav-accent" class="navbar-toggle" hidden>
<label for="nav-accent" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<br>
<p>Full-width colored bar with <code>.bg-primary</code> on the <code><header></code> and <code>.container</code> on the <code><nav></code>:</p>
<header class="bg-primary" style="border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<nav class="container">
<ul>
<li><strong>Full-width</strong></li>
</ul>
<input type="checkbox" id="nav-fullwidth" class="navbar-toggle" hidden>
<label for="nav-fullwidth" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
</section>
<section>
<h2>Active link</h2>
<p>Add <code>.active</code> to bold the current page link.</p>
<nav style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Brand</strong></li>
</ul>
<input type="checkbox" id="nav-active" class="navbar-toggle" hidden>
<label for="nav-active" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#" class="active">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</section>
<section>
<h2>Sticky top</h2>
<p>Add <code>.sticky-top</code> to make the nav stick when scrolling. On a nav, a <code>z-index</code> and <code>box-shadow</code> are added automatically.</p>
<nav class="sticky-top" style="background-color: var(--mu-secondary-background); border-radius: var(--mu-border-radius); padding: 0.5rem 1rem;">
<ul>
<li><strong>Sticky</strong></li>
</ul>
<input type="checkbox" id="nav-sticky" class="navbar-toggle" hidden>
<label for="nav-sticky" class="navbar-burger">☰</label>
<ul class="navbar-menu">
<li><a href="#" class="active">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</section>
</main>
</body>
</html>