xxxxxxxxxx
1
<nav id="sidenav-4" class="sidenav" data-mdb-mode="side" data-mdb-slim="true" data-mdb-slim-collapsed="true" data-mdb-content="#slim-content">
2
<ul class="sidenav-menu">
3
<li class="sidenav-item">
4
<a class="sidenav-link">
5
<i class="far fa-smile me-3"></i
6
><span data-mdb-slim="false">Link 1</span></a
7
>
8
</li>
9
<li class="sidenav-item">
10
<a class="sidenav-link"
11
><i class="fas fa-grin me-3"></i
12
><span data-mdb-slim="false">Category 1</span></a
13
>
14
<ul class="sidenav-collapse">
15
<li class="sidenav-item">
16
<a class="sidenav-link">Link 2</a>
17
</li>
18
<li class="sidenav-item">
19
<a class="sidenav-link">Link 3</a>
20
</li>
21
</ul>
22
</li>
23
<li class="sidenav-item">
24
<a class="sidenav-link"
25
><i class="fas fa-grin-wink me-3"></i
26
><span data-mdb-slim="false">Category 2</span></a
27
>
28
<ul class="sidenav-collapse">
29
<li class="sidenav-item">
30
<a class="sidenav-link">Link 4</a>
31
</li>
32
<li class="sidenav-item">
33
<a class="sidenav-link">Link 5</a>
34
</li>
35
</ul>
36
</li>
37
</ul>
38
</nav>
39
<!-- Sidenav-->
40
41
<!-- Togglers -->
42
<div id="slim-content">
43
<button
44
data-mdb-toggle="sidenav"
45
data-mdb-target="#sidenav-4"
46
class="btn btn-primary"
47
aria-controls="#sidenav-4"
48
aria-haspopup="true"
49
>
50
<i class="fas fa-bars"></i>
51
</button>
52
<button id="slim-toggler" class="btn btn-primary">
53
Toggle slim
54
</button>
55
</div>
56
<!-- Togglers -->
xxxxxxxxxx
1
.page-intro {
2
background-color: white;
3
width: 100vw;
4
min-height: 100vh;
5
}
6
7
img {
8
max-width: 80%;
9
}
10
11
.mdb-page-content {
12
padding-left: 240px;
13
transition: padding 0.3s linear;
14
}
15
16
#toggler {
17
display: none;
18
}
19
20
@media (max-width: 660px) {
21
.mdb-page-content {
22
padding-left: 0px;
23
}
24
25
#toggler {
26
display: unset;
27
}
28
29
.mask img {
30
width: 100%;
31
}
32
}
33
xxxxxxxxxx
1
const sidenav = document.getElementById('sidenav-4');
2
const instance = 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
if (window.innerWidth < 660) {
14
instance.changeMode('over');
15
instance.hide();
16
} else {
17
instance.changeMode('side');
18
instance.show();
19
}
20
};
21
22
setMode();
23
24
// Event listeners
25
26
window.addEventListener('resize', setMode);
Console errors: 0