<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<title>bootstrap5 navbar</title>
<link rel="stylesheet" href="https://ss.netnr.com/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
</head>
<body>
<button class="bsnav-menu-toggle d-lg-none">
<span></span>
<span></span>
<span></span>
</button>
<!-- mask -->
<span class="bsnav-mask"></span>
<nav class="mobile-offcanvas navbar navbar-expand-lg navbar-orange">
<div class="container-fluid">
<div class="bsnav-header">
<button class="btn-close float-end"></button>
</div>
<a class="navbar-brand" href="#">Brand</a>
<!-- left -->
<ul class="navbar-nav">
<li class="nav-item active"> <a class="nav-link" href="#"> Home </a> </li>
<li class="nav-item"><a class="nav-link" href="#"> About </a></li>
<li class="nav-item"><a class="nav-link" href="#"> Services </a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown"> More items </a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Submenu item 1</a></li>
<li><a class="dropdown-item" href="#"> Submenu item 2 </a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"> Submenu item 3 </a></li>
<li><a class="dropdown-item" href="#"> Submenu item 4 </a></li>
<li><a class="dropdown-item" href="#"> Submenu item 5 </a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"> Submenu item 3 </a></li>
<li><a class="dropdown-item" href="#"> Submenu item 4 </a></li>
<li><a class="dropdown-item" href="#"> Submenu item 5 </a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"> Submenu item 3 </a></li>
</ul>
</li>
</ul>
<!-- right -->
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="#"> Menu item </a></li>
<li class="nav-item"><a class="nav-link" href="#"> Menu item </a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown"> Dropdown right </a>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#"> Submenu item 1</a></li>
<li><a class="dropdown-item" href="#"> Submenu item 2 </a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"> Submenu item 3 </a></li>
</ul>
</li>
</ul>
</div>
</nav>
<script src="https://ss.netnr.com/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- https://bootstrap-menu.com/ -->
</body>
</html>
.dropdown:hover {
z-index: 45;
}
.navbar:hover {
z-index: 40;
}
.dropdown .dropdown-menu,
.navbar .dropdown-menu {
margin-top: 0;
box-shadow: 0 2px 4px rgba(34, 34, 34, 0.15);
}
.dropdown .dropdown-menu-end,
.navbar .dropdown-menu-end {
right: 0;
left: auto;
}
/* mask */
.bsnav-mask {
display: block;
height: 100%;
width: 0%;
z-index: 20;
position: fixed;
top: 0;
right: 0;
opacity: 0;
visibility: hidden;
background-color: rgba(34, 34, 34, 0.6);
transition: opacity 0.2s linear, visibility 0.2s, width 2s ease-in;
}
.bsnav-mask.active {
z-index: 25;
transition: opacity 0.3s ease, width 0s;
opacity: 1;
width: 100%;
visibility: visible;
}
body.offcanvas-active {
overflow: hidden;
}
.bsnav-header {
display: none;
}
/*menu-toggle*/
.bsnav-menu-toggle {
position: fixed;
left: 0;
bottom: 0;
z-index: 49;
padding: 10px 15px;
outline: none;
cursor: pointer;
background-color: transparent;
border: 1px solid transparent;
}
.bsnav-menu-toggle span {
background-color: orange;
margin-bottom: 6px;
display: block;
width: 26px;
height: 3px;
}
/* ============ mobile view ============ */
@media all and (max-width: 991px) {
.bsnav-header {
display: block;
}
.mobile-offcanvas {
visibility: hidden;
transform: translateX(-100%);
border-radius: 0;
display: block;
position: fixed;
top: 0;
left: 0;
height: 100%;
z-index: 48;
width: 80vw;
overflow-y: scroll;
overflow-x: hidden;
padding-bottom: 45px;
transition: visibility 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.mobile-offcanvas.show {
visibility: visible;
transform: translateX(0);
}
.mobile-offcanvas .container,
.mobile-offcanvas .container-fluid {
display: block;
}
.navbar-brand {
padding-left: .7rem;
}
}
/* mobile view .end */
/* desktop */
@media all and (min-width: 992px) {
.navbar {
padding: 0;
}
.navbar .nav-item .dropdown-menu {
display: none;
}
.navbar .nav-item:hover .dropdown-menu {
display: block;
}
.navbar .nav-item .dropdown-menu {
margin-top: 0;
}
}
/* desktop .end */
/* orange theme */
.navbar-orange {
background-color: #ffca2a;
box-shadow: 0 2px 3px rgba(100, 100, 100, 0.1);
font-size: 14px;
}
.navbar-orange .navbar-brand {
font-weight: 600;
display: block;
}
.navbar-orange .navbar-nav .nav-link {
color: #444;
padding: 0.7rem;
font-weight: 600;
border: 2px solid transparent;
}
.navbar-orange .navbar-nav .nav-item.show .nav-link,
.navbar-orange .navbar-nav .nav-item:hover .nav-link {
color: #0d6efd;
}
.navbar-orange .dropdown-menu {
border: 0;
background-clip: initial;
border-radius: 0;
box-shadow: 0 1px 5px rgba(70, 70, 70, 0.2);
}
.navbar-orange .dropdown-menu .dropdown-item {
padding: 0.6rem 1.5rem;
}