Utilizing the Bootstrap class bg-dark
on the navbar
element results in a seamless user experience by ensuring consistency in design. Incorporating a dark gray navbar with a white dropdown can create excessive color contrast, impacting usability. However, you have the flexibility to include a white dropdown within a dark gray navbar if desired.
To implement this design, add the following CSS:
.navbar-nav .dropdown-menu {
background-color: white;
}
.navbar-nav .dropdown-item {
color: black;
}
.navbar-nav .dropdown-divider {
border-top: 1px solid black;
}
.navbar-nav .dropdown-item:hover {
background-color: lightgrey;
color: black;
}
Review the code snippet below for reference.
.navbar-nav .dropdown-menu {
background-color: white;
}
.navbar-nav .dropdown-item {
color: black;
}
.navbar-nav .dropdown-divider {
border-top: 1px solid black;
}
.navbar-nav .dropdown-item:hover {
background-color: lightgrey;
color: black;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9bbb6b6adaaadabb8a9f4b0bab6b7aa99e8f7e8e9f7ec">[email protected]</a>/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e7858888939493958697a7d2c9d4c9d7ca868b978f86d4">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous"></head>
<body>
<nav class="navbar navbar-expand-lg bg-dark " data-bs-theme="dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="SupportedContent">
<form class="d-flex ms-auto">
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
<button class="btn btn-outline-secondary" type="button" id="button-addon2"><i
class="bi bi-search"></i></button>
</div>
</form>
<ul class="navbar-nav mb-3">
<li class="nav-item dropdown ">
<a class="nav-link dropdown-toggle show" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="true">
<i class="bi bi-person-fill"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" data-bs-popper="static">
<li><a class="dropdown-item " href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<ul class="navbar-nav mb-3">
<li class="nav-item dropdown ">
<a class="nav-link dropdown-toggle show" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="true">
<i class="bi bi-person-fill"></i>
</a>
<ul class="dropdown-menu " data-bs-popper="static">
<li><a class="dropdown-item " href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b0904041f181f190a1b2b5e4558455b460a071b030a58">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
</body>
</html>