<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-13.png" data-lazy- height="260" src="data:image/svg xml,” width=”944″>
tag are created.
Vertical Pills
To create vertical pills just add a class .flex-column with .nav-pills class.
<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-14.png" data-lazy- height="226" src="data:image/svg xml,” width=”812″>
<div class = “container” style = “margin-top: 10px;” >
<ul class = “nav nav-pills flex-column” >
<li class = “nav-item” >
<a class = “nav-link active” aria-current= “page” href = “#” >Home</ a >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >About</ a >
</ li >
<li class = “nav-item dropdown” >
<a class = “nav-link dropdown-toggle” data-bs-toggle= “dropdown” href = “#” role= “button” aria-expanded= “false” >Products</ a >
<ul class = “dropdown-menu” >
<li ><a class = “dropdown-item” href = “#” >Product 1 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 2 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 3 </ a ></ li >
</ ul >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >Contact</ a >
</ li >
</ ul >
</ div >
Fill and justify Tabs and Pills menu
.nav-fill class is used to fill spaces in unjustified manner while .nav-justified class is used to fill spaces in justified manner.
Tabs with .nav-fill To fill the uncovered spaces of a container just add .nav-fill class with .nav nav-tabs . But the .nav-fill class only filled the spaces but didn’t justify them.
<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-15.png" data-lazy- height="110" src="data:image/svg xml,” width=”866″>
<div class = “container” style = “margin-top: 10px;” >
<ul class = “nav nav-tabs nav-fill” >
<li class = “nav-item” >
<a class = “nav-link active” aria-current= “page” href = “#” >Home</ a >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >About</ a >
</ li >
<li class = “nav-item dropdown” >
<a class = “nav-link dropdown-toggle” data-bs-toggle= “dropdown” href = “#” role= “button” aria-expanded= “false” >Products</ a >
<ul class = “dropdown-menu” >
<li ><a class = “dropdown-item” href = “#” >Product 1 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 2 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 3 </ a ></ li >
</ ul >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >Contact</ a >
</ li >
</ ul >
</ div >
This is how tabs with .nav-fill are created.
Tabs with .nav-justified
.nav-justified class not only fills the ideal spaces but also distributes it equally among all the nav items.
<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-16.png" data-lazy- height="116" src="data:image/svg xml,” width=”854″>
<div class = “container” style = “margin-top: 10px;” >
<ul class = “nav nav-tabs nav-justified” >
<li class = “nav-item” >
<a class = “nav-link active” aria-current= “page” href = “#” >Home</ a >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >About</ a >
</ li >
<li class = “nav-item dropdown” >
<a class = “nav-link dropdown-toggle” data-bs-toggle= “dropdown” href = “#” role= “button” aria-expanded= “false” >Products</ a >
<ul class = “dropdown-menu” >
<li ><a class = “dropdown-item” href = “#” >Product 1 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 2 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 3 </ a ></ li >
</ ul >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >Contact</ a >
</ li >
</ ul >
</ div >
This is how tabs with .nav-justified are created.
Pills with .nav-fill
To fill the uncovered spaces of a container just add a .nav-fill class with .nav nav-pills . But the .nav-fill class only filled the spaces but didn’t justify them.
<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-17.png" data-lazy- height="118" src="data:image/svg xml,” width=”824″>
<div class = “container” style = “margin-top: 10px;” >
<ul class = “nav nav-pills nav-fill” >
<li class = “nav-item” >
<a class = “nav-link active” aria-current= “page” href = “#” >Home</ a >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >About</ a >
</ li >
<li class = “nav-item dropdown” >
<a class = “nav-link dropdown-toggle” data-bs-toggle= “dropdown” href = “#” role= “button” aria-expanded= “false” >Products</ a >
<ul class = “dropdown-menu” >
<li ><a class = “dropdown-item” href = “#” >Product 1 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 2 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 3 </ a ></ li >
</ ul >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >Contact</ a >
</ li >
</ ul >
</ div >
This is how pills with .nav-fill are created.
Pills with .nav-justified
.nav-justified class not only fills the ideal spaces but also distributes it equally among all the nav items.
<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/bootstrap-nav-menus-18.png" data-lazy- height="112" src="data:image/svg xml,” width=”832″>
<div class = “container” style = “margin-top: 10px;” >
<ul class = “nav nav-pills nav-justified” >
<li class = “nav-item” >
<a class = “nav-link active” aria-current= “page” href = “#” >Home</ a >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >About</ a >
</ li >
<li class = “nav-item dropdown” >
<a class = “nav-link dropdown-toggle” data-bs-toggle= “dropdown” href = “#” role= “button” aria-expanded= “false” >Products</ a >
<ul class = “dropdown-menu” >
<li ><a class = “dropdown-item” href = “#” >Product 1 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 2 </ a ></ li >
<li ><a class = “dropdown-item” href = “#” >Product 3 </ a ></ li >
</ ul >
</ li >
<li class = “nav-item” >
<a class = “nav-link” href = “#” >Contact</ a >
</ li >
</ ul >
</ div >
This is how pills with .nav-justified are created.
Conclusion
Nav menus are created using
and
tags and bootstrap classes .nav, .nav-items, .nav-link, .nav-tabs, .nav-pills. For the horizontal alignment “.justify-content-start/center/end ” are used. For vertical alignment the “.flex-column ” class is used. To fill the ideal spaces in a container, use “.nav-fill ” and “.nav-justified ” with “.nav-tabs ” and “.nav-pills ” classes. The above article contains knowledge regarding main and commonly used bootstrap 5 classes and tags to create nav menus.