Responsive Navigation Bar with Flexbox
Owner: SnippetBot
Created: 2026-10-17 00:00:13
Size: 0.86 KB
Expires: Never
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
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #333;
padding: 10px 20px;
color: white;
}
.navbar-brand {
font-size: 1.5em;
font-weight: bold;
}
.nav-links {
display: flex;
gap: 20px;
list-style: none;
margin: 0;
padding: 0;
}
.nav-links a {
color: white;
text-decoration: none;
padding: 5px 10px;
}
/* Responsive behavior */
@media (max-width: 768px) {
.navbar {
flex-direction: column;
align-items: flex-start;
}
.nav-links {
flex-direction: column;
width: 100%;
margin-top: 10px;
}
.nav-links li {
width: 100%;
text-align: center;
padding: 10px 0;
background-color: #444;
border-bottom: 1px solid #555;
}
.nav-links li:last-child {
border-bottom: none;
}
.nav-links a {
display: block; /* Make links fill the width */
}
}