HTML
xxxxxxxxxx
1
<!--Main Navigation-->
2
<header>
3
<!-- Animated navbar-->
4
<nav
5
class="navbar navbar-expand-lg fixed-top navbar-scroll"
6
[class.navbar-scrolled]="navbarScrolled"
7
>
8
<div class="container-fluid">
9
<button
10
class="navbar-toggler"
11
type="button"
12
(click)="animatedNavbarExample2.toggle()"
13
aria-controls="animatedNavbarExample2"
14
aria-expanded="false"
15
aria-label="Toggle navigation"
16
>
17
<span class="navbar-toggler-icon d-flex justify-content-start align-items-center">
18
<i class="fas fa-bars"></i>
19
</span>
20
</button>
21
<div
22
mdbCollapse
23
#animatedNavbarExample2="mdbCollapse"
24
class="collapse navbar-collapse"
25
id="animatedNavbarExample2"
26
>
27
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
28
<li class="nav-item active">
29
<a class="nav-link" aria-current="page" href="#intro">Home</a>
30
</li>
31
<li class="nav-item">
32
<a
33
class="nav-link"
34
href="https://www.youtube.com/channel/UC5CF7mLQZhvx8O5GODZAhdA"
35
rel="nofollow"
36
target="_blank"
37
>Learn Bootstrap 5</a
38
>
39
</li>
40
<li class="nav-item">
41
<a class="nav-link" href="https://mdbootstrap.com/docs/standard/" target="_blank"
42
>Download MDB UI KIT</a
43
>
44
</li>
45
</ul>
46
47
<ul class="navbar-nav flex-row">
48
<!-- Icons -->
49
<li class="nav-item">
50
<a
51
class="nav-link pe-2"
52
href="https://www.youtube.com/channel/UC5CF7mLQZhvx8O5GODZAhdA"
53
rel="nofollow"
54
target="_blank"
55
>
56
<i class="fab fa-youtube"></i>
57
</a>
58
</li>
59
<li class="nav-item">
60
<a
61
class="nav-link px-2"
62
href="https://www.facebook.com/mdbootstrap"
63
rel="nofollow"
64
target="_blank"
65
>
66
<i class="fab fa-facebook-f"></i>
67
</a>
68
</li>
69
<li class="nav-item">
70
<a
71
class="nav-link px-2"
72
href="https://twitter.com/MDBootstrap"
73
rel="nofollow"
74
target="_blank"
75
>
76
<i class="fab fa-twitter"></i>
77
</a>
78
</li>
79
<li class="nav-item">
80
<a
81
class="nav-link ps-2"
82
href="https://github.com/mdbootstrap/mdb-ui-kit"
83
rel="nofollow"
84
target="_blank"
85
>
86
<i class="fab fa-github"></i>
87
</a>
88
</li>
89
</ul>
90
</div>
91
</div>
92
</nav>
93
<!-- Animated navbar -->
94
95
<!-- Background image -->
96
<div
97
id="intro"
98
class="bg-image"
99
style="
100
background-image: url(https://mdbcdn.b-cdn.net/img/new/fluid/city/113.webp);
101
height: 100vh;
102
"
103
>
104
<div class="mask text-white" style="background-color: rgba(0, 0, 0, 0.8)">
105
<div class="container d-flex align-items-center text-center h-100">
106
<div>
107
<h1 class="mb-5">This is title</h1>
108
<p>
109
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis molestiae laboriosam
110
numquam expedita ullam saepe ipsam, deserunt provident corporis, sit non accusamus
111
maxime, magni nulla quasi iste ipsa architecto? Autem!
112
</p>
113
</div>
114
</div>
115
</div>
116
</div>
117
<!-- Background image -->
118
</header>
119
<!--Main Navigation-->
120
121
<div class="container my-5">
122
<p>
123
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Nobis quam minima perspiciatis eos
124
tenetur. Praesentium dolores at quos aperiam sed, sint provident consectetur incidunt, nostrum
125
porro earum commodi, ex architecto.
126
</p>
127
</div>
128
SCSS
1
1
JS (TypeScript)
xxxxxxxxxx
1
import { Component, OnInit } from '@angular/core';
2
import { fromEvent } from 'rxjs';
3
4
@Component({
5
selector: 'app-root',
6
templateUrl: './app.component.html',
7
styleUrls: ['./app.component.scss']
8
})
9
export class AppComponent implements OnInit {
10
constructor() {}
11
12
navbarScrolled = false;
13
14
ngOnInit(): void {
15
fromEvent(window, 'scroll').subscribe(() => {
16
if (window.scrollY > 0) {
17
this.navbarScrolled = true;
18
} else {
19
this.navbarScrolled = false;
20
}
21
});
22
}
23
}
Console errors: 0