I have tried to design a dark dropdown menu using Bootstraps dropdown
classes and additional styling via CSS. The problem is that when the mouse hovers over the dropdown-items they turn totally white (white text on brightbackground). See the result in this image:
The code for the image above is showed below. I have used inline styles to clarify:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown menu
</button>
<div class="dropdown-menu" style="background-color: black" >
<a class="dropdown-item" style="color:white" href="#">Item 1</a>
<a class="dropdown-item" style="color:white" href="#">Item 2</a>
<a class="dropdown-item" style="color:white" href="#">Item 3</a>
</div>
</div>
</div>
</body>
</html>
I can't find how I can change the hover behaviour or style. I would like the text to turn dark for readibility. How can I achieve this? Are there any classes or other tricks in Bootstrap?
question from:
https://stackoverflow.com/questions/65934014/changing-background-color-for-drowpdown-makes-selected-items-totally-white-in-bo 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…