I have been trying everything to change the background-color & color of the dropdown with no success (dropdown-menu & dropdown-item). Now the background color of the dropdown is very light grey and the hover on each item has a medium light grey background and a yellow color which are not very contrasted and I need to change them.
/* navbar */
.navbar-nav {
font-weight: bold !important;
}
/* navbar bgn color */
.nav-item a,
.nav-item a:link,
.nav-item a:visited {
color: var(--bodyPage) !important;
}
/* navbar item font color */
.nav-item a:hover,
.nav-item a:focus {
color: var(--linkHover) !important;
}
/* navbar item hover font color */
.active a,
.nav-item .active a:link,
.active a:visited {
color: var(--navActive) !important;
}
/* active navbar item font color */
.active a:hover,
.active a:focus {
color: var(--linkHover) !important;
}
/* active navbar item hover font color */
/* links */
a,
a:link,
a:visited {
color: var(--link);
}
a:hover,
a:focus {
color: var(--linkHover);
}
.site-footer a,
.site-footer a:link,
.site-footer a:visited {
color: var(--link);
}
/* footer link color */
.site-footer a:hover,
.site-footer a:focus {
color: var(--linkHover);
}
/* footer hover link color */
.site-page a,
.site-page a:link,
.site-page a:visited {
color: var(--link);
}
/* page body link color */
.site-page a:hover,
.site-page a:focus {
color: var(--linkHover);
}
/* page body hover link color */
.banner a,
.banner a:link,
.banner a:visited {
color: var(--link);
}
/* banner link color */
.banner a:hover,
.banner a:focus {
color: var(--linkHover);
}
/* banner hover link color */
.no-banner a,
.no-banner a:link,
.no-banner a:visited {
color: var(--link);
}
/* no banner link color */
.no-banner a:hover,
.no-banner a:focus {
color: var(--linkHover);
}
/* no banner hover link color */
.navbar-default .navbar-toggle {
background-color: red !important;
}
@media (max-width:992px) {
.navbar-nav {
background-color: black !important;
padding: 8px !important;
}
}
/* dropdown menu */
.dropdown-menu {
background-color: rgb(99, 97, 97) !important;
}
.dropdown-item a:hover {
background-color: rgb(0, 0, 0) !important;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<body data-spy="scroll" data-target=".site-navbar-target" data-offset="300">
<div class="site-wrap" id="home-section">
<header class="container-fluid sticky site-header" id="headerSite">
<div class="container">
<nav class="navbar navbar-expand-md navbar-light">
<div class="collapse navbar-collapse justify-content-between" id="navbarCollapse">
<div class="navbar-nav mr-auto">
<li class="nav-item"><a href="/dashboard" class="nav-link">Dashboard</a></li>
<div class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="dropdownNav" data-bs-toggle="dropdown">database</a>
<div class="dropdown-menu" aria-labelledby="dropdownNav">
<a href="..." class="dropdown-item">table1</a>
<a href="..." class="dropdown-item">table2</a>
<a href="..." class="dropdown-item">table3</a>
</div>
</div>
</div>
</div>
</nav>
</div>
</header>
3
Answers
It looks like you’ve got some HTML issues, and I wasn’t able to even view the dropdown menu in your example. This way works for me, and I can see the color changed in the dropdown menu. It’s not clear what colors you want exactly, but this might get you there.
Add a custom css file (e.g. style.css) and add reference to it below your bootstrap css reference (e.g.
<link rel="stylesheet" href="path-to-your-css-file/style.css">
)Add a new class to custom class to the elements you want to modify and color that class as per your requirement.
e.g.
<a href="#" class="nav-link dropdown-toggle custom-dropdown" id="dropdownNav" data-bs-toggle="dropdown">database</a>
Here is your solution…
now it change successfully