Bootstrap 5 Navbar Menu

Bootstrap 5 Navbars

Bootstrap 5 navbars have collapsed and expanded features. It works on the basis of available screen size. Navbar expands features to expand the navbar in the available space at the mentioned breakpoint while as navbar collapse collapses the navbar in the small devices.

Bootstrap 5 Basic Horizontal Navbar

Step To Create Bootstrap Basic Horizontal Navbar Menu

  • Add .navbar,.navbar-expand{-sm|-md|-lg|-xl} & background color utility.navbar-light & .bg-light to <nav> base class.
  • Add .navbar-nav to <ul> base class.
  • Add .nav-item to <li> base class.
  • Add .nav-link to <a> base class.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention step to create a bootstrap basic navigation.

Navbar Brand & Collapsing

bootsrap .navbar-brand shows brand name of company or brand logo.

By applying .navbar-brand class on images, It adjusts image to fit vertically with respect to navbar.

Navbar: Brand Name

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create bootstrap navbar having brand name.

Navbar: Brand Logo

Place brand logo inside .navbar-brand element.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create bootstrap navbar having brand logo.

Dropdown Split Buttons

Add .dropdown-toggle-split to the <button> having .dropdown-toggle.It is used for proper spacing around the dropdown caret.

General Syntax

Try it now

Source Code

Try it now

Source Code : Output

Code Explanation

Note: Please keep in mind that assign an additional .dropdown-toggle-split class to the <button> element base class to make dropdown split buttons.

Navbar: Collapsing

Use collapse concept inside navbar to create collapsing navbar.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create bootstrap navbar having collapsing features.

Navbar:Vertical Navbar

Steps To Create Vertical Navbar Menu

  • Add .navbar & background color utility.navbar-light .bg-light to <nav> base class.
  • Add .navbar-nav to <ul> base class.
  • Add .nav-item to <li> base class.
  • Add .nav-link to <a> base class.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create bootstrap vertical navbar.

Centered Navbar

Add the .justify-content-center class to center the navigation bar.

  • Add .navbar,.navbar-expand-sm,.justify-content-center & background color utility.navbar-light .bg-light to <nav> base class.
  • Add .navbar-nav to <ul> element base class.
  • Add .nav-item to <li> element base class.
  • Add .nav-link to <a> element base class.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above mention steps to create bootstrap centered navbar.

Navbar:Background Color

To change navbar background color ,navbar background color can be change very easily.use .navbar-dark for dark background-color and .navbar-light for light background-color.Then customize it,with the background-color utility classes i.e bg-*.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Follow the above steps to create bootstrap colored navbar.

Navbar With Dropdown

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: Follow the above steps to create bootstrap navbar having dropdown feature.

Search Form With Navbar

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:Here,search form and button both are placed inside navbar.

Navbar Brand With Search Form

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:To place <form> element inside navbar, assign .d-flex to the <form> element base class and assign .form-control to the <form> input control.

Navbar With Addon

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note:To place <form> element inside navbar, assign .container-fluid to the <form> element base class and assign .input-group to the form controls container base class.At the end,place addon inside <span> element and assign .input-group-text to the <span> element base class and also assign .form-control to the input form control base class.

Navbar:Text

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: To place text inside the navbar,write text information inside the <span> element and provide .navbar-text to the <span> element base class.

Navbar:Container

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: Navbar and container both are used at a time.

Navbar: Fixed Top

The navigation bar can also be fixed at the top or at the bottom of the page. A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll.The .fixed-top class makes the navigation bar fixed at the top:

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: To create fixed top navbar,assign .fixed-top to the navbar base class.

Navbar: Fixed Bottom

Use the .fixed-bottom class to make the navbar stay at the bottom of the page.

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: To create fixed bottom navbar,assign .fixed-bottom to the <nav> element base class.

Bootstrap 5 Navbars:Sticky Top

Use the .sticky-top class to make the navbar fixed/stay at the top of the page when you scroll the page. This class does not work in IE11 and earlier (will treat it as position: relative).

General Syntax

Try it now

Source Code

Try it now

Code Explanation

Note: To create bootstrap 5 navbars having sticky top feature, assign .sticky-top to the <nav> element base class.

Online Test / Quiz