英文:
Bootstrap dropdown on toggle change background color
问题
我已经有这段代码:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle buttonForProfile" type="button" id="dropdownMenuButton" data-bs-toggle='dropdown' aria-haspopup="true" aria-expanded="false">
<?php echo $_SESSION['username']; ?>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">Subscriptions</a>
<a class="dropdown-item" href="./php/signout.php">Sign out</a>
</div>
</div>
我添加了一些 CSS,现在它看起来像这样:
当我点击它时,背景颜色会恢复为默认值:
如何在下拉菜单切换时更改那个灰色背景?
英文:
I have this code:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle buttonForProfile" type="button" id="dropdownMenuButton" data-bs-toggle='dropdown' aria-haspopup="true" aria-expanded="false">
<?php echo $_SESSION['username']; ?>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">Subscriptions</a>
<a class="dropdown-item" href="./php/signout.php">Sign out</a>
</div>
</div>
I added some css and now it looks like this:
When I click on it, the background changes back to default:
How do I change that gray background when the dropdown is toggled?
答案1
得分: 1
#dropdownMenuButton:focus {
background-color: //颜色;
}
PS: btn-secondary 给它灰色,如果你自定义颜色,就不需要它。
英文:
#dropdownMenuButton:focus {
background-color: //color;
}
PS: btn-secondary gives it the grey color, you don't need it if you're customizing the color.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论