In this tutorial, we are going to see how to integrate navbar in bootstrap 5. Navbar is fully responsive. Navbar auto extend or collapse as per screen size.
Navbar in boostrap 5 is created by using .navbar class.
A navigation bar is also called a Navbar that contains links of the other pages it is an essential part of the page it comes under header section.
Bootstrap 5 gives us navbar without doing any manual coding. It is fully responsive and can also be fixed.
Firstly, we have to add, Bootstrap 5 js and CSS CDN link in head section of web page. You can copy the below code for direct CDN link of js and CSS.
Paste in head section.
<!---------- Paste This in head section -------->
<>
<><>
<!---------- Paste This in head section -------->
Here in this tutorial we are creating examples of responsive navbar which is helpful to create a main menu section in a website.
Here we creating a simple navbar through bootstrap 5.
index.html
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 1<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>
<>
<>Link 1<>
<>
<>
<>Link 2<>
<>
<>
<>Link 3<>
<>
<>
<>
<>
<>
<>
<>
<>
<>Demo 1 - Simple Navbar<>
<>This is my first simple navbar<>
<>
<>
<>
<>
<>
<>
Here we creating navbar with logo through bootstrap 5.
index.html
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 2<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>Logo<>
<>
<><>
<>
<>
<>
<>
<>Link 1<>
<>
<>
<>Link 2<>
<>
<>
<>Link 3<>
<>
<>
<>Link 4<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>Demo 2 - Navbar With Logo And Menu<>
<>This is Navbar With Logo And Menu<>
<>
<>
<>
<>
<>
<>
Here we creating Navbar With Logo And Drop Down Menu through bootstrap 5.
index.html
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 3<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>Home<>
<>
<>
<>Link 1<>
<>
<>
<>Link 2<>
<>
<>
<> Dropdown <>
<>
<>
<>Action<>
<>
<>
<>Another action<>
<>
<>
<>
<>
<>
<>Something else here<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>Demo 3 - Navbar With Logo And Drop Down Menu<>
<>This is Navbar With Logo And Drop Down Menu<>
<>
<>
<>
<>
<>
<>
Here we creating navbar fixed on top through bootstrap 5.
index.html
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 4<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>LOGO <><>
<>
<>
<><>
<>
<>
<>
<>
<>
<>Home<>
<>
<>
<>
<>
<>About Us<>
<>
<>
<>
<>
<>Services<>
<>
<>
<>
<>
<>Blog<>
<>
<>
<>
<>
<>Contact Us<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>Demo 4 - Navbar With Fixed Header On Top<>
<>This is Navbar With Fixed Header On Top. To test this please scroll down.<>
<>
<>
<>
<>
<>
<>
Here we creating navbar fixed on top and class are dynamic through bootstrap 5.
index.html
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 6<>
<>
<>
<>
<><>
<>
<>
<!---------------Nav Bar Start -------------------->
<>
<> <>LOGO<><><>
<> <><> <>
<>
<>
<> <><>Home<><><>
<> <><>About Us<><><>
<> <><>Services<><><>
<> <><>Blog<><><>
<> <><>Contact Us<><><>
<>
<>
<>
<>
<!--------------- Nav Bar End-------------------->
<>
<>
<>
<>
<>Demo 6 - Navbar With Fixed Header On Top And Dynamic Class in Header<>
<>This is Navbar With Fixed Header On Top And Dynamic Class in Header. To test this please scroll down.<>
<>
<>
<>
<>
<>
/* To Add Class On Scroll */
window.onscroll = function() {
if (document.body.scrollTop > 30 || document.documentElement.scrollTop > 30) {
document.getElementById("navbar_top").classList.add('header-fixed');
} else {
document.getElementById("navbar_top").classList.remove('header-fixed')
}
};
<>
<>
<>
Here we creating navbar open from left side through bootstrap 5.
index
<>
<>
<>
<>Bootstrap 5 Navbar Example - Demo 7<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>Offcanvas dark navbar<>
<>
<><>
<>
<>
<>
<>Dark offcanvas<>
<><>
<>
<>
<>
<>
<>Home<>
<>
<>
<>Link<>
<>
<>
<> Dropdown <>
<>
<>
<>Action<>
<>
<>
<>Another action<>
<>
<>
<>
<>
<>
<>Something else here<>
<>
<>
<>
<>
<>
<>
<>Search<>
<>
<>
<>
<>
<>
<>
<>
<>
<>
<>Demo 7 - Navbar Open With Left Side Bar<>
<>This is Navbar Open With Left Side Bar. To test this please click on nav bar.<>
<>
<>
<>
<>
<>
<>
Here we going to create Ecommerce Navbar Open With Search And Cart Button through bootstrap 5.
index.html
<>
<>
<>Bootstrap 5 Navbar Example - Demo 8<>
<>
<>
<>
<><>
<>
<>
<>
<>
<>
<>
<>
<>LOGO<>
<>
<>
<>
<>
<> <>Home<> <>
<> <>Category<> <>
<> <>Menu List<> <>
<> <>Our Services<> <>
<> <>Testimonial<> <>
<> <>Contact Us<> <>
<>
<>
<>
<>
<> <><> <>
<><><><>
<><><><>
<>
<>
<>
<>
<>
<>
<>