HTML
xxxxxxxxxx
1
<!--Main Navigation-->
2
<header>
3
<!-- Sidenav-->
4
<nav
5
id="sidenav-4"
6
class="sidenav"
7
data-mdb-mode="side"
8
data-mdb-content="#slim-content"
9
>
10
<ul class="sidenav-menu">
11
<li class="sidenav-item">
12
<a class="sidenav-link">
13
<i class="far fa-smile me-3"></i
14
><span data-mdb-slim="false">Link 1</span></a
15
>
16
</li>
17
<li class="sidenav-item">
18
<a class="sidenav-link"
19
><i class="fas fa-grin me-3"></i
20
><span data-mdb-slim="false">Category 1</span></a
21
>
22
<ul class="sidenav-collapse">
23
<li class="sidenav-item">
24
<a class="sidenav-link">Link 2</a>
25
</li>
26
<li class="sidenav-item">
27
<a class="sidenav-link">Link 3</a>
28
</li>
29
</ul>
30
</li>
31
<li class="sidenav-item">
32
<a class="sidenav-link"
33
><i class="fas fa-grin-wink me-3"></i
34
><span data-mdb-slim="false">Category 2</span></a
35
>
36
<ul class="sidenav-collapse">
37
<li class="sidenav-item">
38
<a class="sidenav-link">Link 4</a>
39
</li>
40
<li class="sidenav-item">
41
<a class="sidenav-link">Link 5</a>
42
</li>
43
</ul>
44
</li>
45
</ul>
46
</nav>
47
<!-- Sidenav-->
48
49
<!-- Navbar -->
50
<nav
51
id="main-navbar"
52
class="navbar navbar-expand-lg navbar-light bg-white fixed-top"
53
>
54
<!-- Container wrapper -->
55
<div class="container-fluid">
56
<!-- Toggler -->
57
<button
58
data-mdb-toggle="sidenav"
59
data-mdb-target="#sidenav-4"
60
class="btn shadow-0 p-0 me-3 d-block d-xxl-none"
61
aria-controls="#sidenav-4"
62
aria-haspopup="true"
63
>
64
<i class="fas fa-bars fa-lg"></i>
65
</button>
66
<button id="slim-toggler" class="btn shadow-0 p-0 me-3 d-none d-xxl-block">
67
<i class="fas fa-bars fa-lg"></i>
68
</button>
69
70
<!-- Search form -->
71
<form class="d-none d-md-flex input-group w-auto my-auto">
72
<input
73
autocomplete="off"
74
type="search"
75
class="form-control rounded"
76
placeholder='Search (ctrl + "/" to focus)'
77
style="min-width: 225px"
78
/>
79
<span class="input-group-text border-0"
80
><i class="fas fa-search"></i
81
></span>
82
</form>
83
84
<!-- Right links -->
85
<ul class="navbar-nav ms-auto d-flex flex-row">
86
<!-- Notification dropdown -->
87
<li class="nav-item dropdown">
88
<a
89
class="nav-link me-3 me-lg-0 dropdown-toggle hidden-arrow"
90
href="#"
91
id="navbarDropdownMenuLink"
92
role="button"
93
data-mdb-toggle="dropdown"
94
aria-expanded="false"
95
>
96
<i class="fas fa-bell"></i>
97
<span class="badge rounded-pill badge-notification bg-danger"
98
>1</span
99
>
100
</a>
101
<ul
102
class="dropdown-menu dropdown-menu-end"
103
aria-labelledby="navbarDropdownMenuLink"
104
>
105
<li><a class="dropdown-item" href="#">Some news</a></li>
106
<li><a class="dropdown-item" href="#">Another news</a></li>
107
<li>
108
<a class="dropdown-item" href="#">Something else here</a>
109
</li>
110
</ul>
111
</li>
112
113
<!-- Icon -->
114
<li class="nav-item">
115
<a class="nav-link me-3 me-lg-0" href="#">
116
<i class="fas fa-fill-drip"></i>
117
</a>
118
</li>
119
<!-- Icon -->
120
<li class="nav-item me-3 me-lg-0">
121
<a class="nav-link" href="#">
122
<i class="fab fa-github"></i>
123
</a>
124
</li>
125
126
<!-- Icon dropdown -->
127
<li class="nav-item dropdown">
128
<a
129
class="nav-link me-3 me-lg-0 dropdown-toggle hidden-arrow"
130
href="#"
131
id="navbarDropdown"
132
role="button"
133
data-mdb-toggle="dropdown"
134
aria-expanded="false"
135
>
136
<i class="united kingdom flag m-0"></i>
137
</a>
138
<ul
139
class="dropdown-menu dropdown-menu-end"
140
aria-labelledby="navbarDropdown"
141
>
142
<li>
143
<a class="dropdown-item" href="#"
144
><i class="united kingdom flag"></i>English
145
<i class="fa fa-check text-success ms-2"></i
146
></a>
147
</li>
148
<li><hr class="dropdown-divider" /></li>
149
<li>
150
<a class="dropdown-item" href="#"
151
><i class="poland flag"></i>Polski</a
152
>
153
</li>
154
<li>
155
<a class="dropdown-item" href="#"
156
><i class="china flag"></i>中文</a
157
>
158
</li>
159
<li>
160
<a class="dropdown-item" href="#"
161
><i class="japan flag"></i>日本語</a
162
>
163
</li>
164
<li>
165
<a class="dropdown-item" href="#"
166
><i class="germany flag"></i>Deutsch</a
167
>
168
</li>
169
<li>
170
<a class="dropdown-item" href="#"
171
><i class="france flag"></i>Français</a
172
>
173
</li>
174
<li>
175
<a class="dropdown-item" href="#"
176
><i class="spain flag"></i>Español</a
177
>
178
</li>
179
<li>
180
<a class="dropdown-item" href="#"
181
><i class="russia flag"></i>Русский</a
182
>
183
</li>
184
<li>
185
<a class="dropdown-item" href="#"
186
><i class="portugal flag"></i>Português</a
187
>
188
</li>
189
</ul>
190
</li>
191
192
<!-- Avatar -->
193
<li class="nav-item dropdown">
194
<a
195
class="nav-link dropdown-toggle hidden-arrow d-flex align-items-center"
196
href="#"
197
id="navbarDropdownMenuLink"
198
role="button"
199
data-mdb-toggle="dropdown"
200
aria-expanded="false"
201
>
202
<img
203
src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/img (31).webp"
204
class="rounded-circle"
205
height="22"
206
alt="Avatar"
207
loading="lazy"
208
/>
209
</a>
210
<ul
211
class="dropdown-menu dropdown-menu-end"
212
aria-labelledby="navbarDropdownMenuLink"
213
>
214
<li><a class="dropdown-item" href="#">My profile</a></li>
215
<li><a class="dropdown-item" href="#">Settings</a></li>
216
<li><a class="dropdown-item" href="#">Logout</a></li>
217
</ul>
218
</li>
219
</ul>
220
</div>
221
<!-- Container wrapper -->
222
</nav>
223
<!-- Navbar -->
224
</header>
225
<!--Main Navigation-->
226
227
<!--Main layout-->
228
<main style="margin-top: 58px">
229
<div class="container">
230
231
</div>
232
</main>
233
<!--Main layout-->
234
235
<!--Footer-->
236
<footer></footer>
237
<!--Footer-->
CSS
xxxxxxxxxx
1
@media (min-width: 1400px) {
2
main,
3
header,
4
#main-navbar,
5
#slim-toggler {
6
padding-left: 240px;
7
}
8
}
JS
xxxxxxxxxx
1
const sidenav = document.getElementById("sidenav-4");
2
const sidenavInstance = mdb.Sidenav.getInstance(sidenav);
3
4
let innerWidth = null;
5
6
const setMode = (e) => {
7
// Check necessary for Android devices
8
if (window.innerWidth === innerWidth) {
9
return;
10
}
11
12
innerWidth = window.innerWidth;
13
14
if (window.innerWidth < 1400) {
15
sidenavInstance.update({slimCollapsed: false, slim: true})
16
sidenavInstance.changeMode("over");
17
sidenavInstance.hide();
18
} else {
19
sidenavInstance.update({slim:true, slimCollapsed: true})
20
sidenavInstance.changeMode("side");
21
sidenavInstance.show();
22
}
23
};
24
25
setMode();
26
27
// Event listeners
28
window.addEventListener("resize", setMode);
29
30
document.getElementById('slim-toggler').addEventListener('click', () => {
31
sidenavInstance.toggleSlim();
32
})
Console errors: 0