gpt4 book ai didi

css - 单击时如何更改 Bootstrap 导航栏下拉菜单的颜色?

转载 作者:太空宇宙 更新时间:2023-11-03 21:27:44 28 4
gpt4 key购买 nike

我试图在单击或选择时更改 Bootstrap 导航栏下 zipper 接的颜色。现在它会瞬间变成指定的颜色,然后又切换回默认的灰色。这是我的 CSS:

li.dropdown:active {
background-color: teal;
}

下拉列表:

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="nav-text">Office Info</span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="faq.php">FAQ</a></li>
<li><a href="privacy.php">Privacy</a></li>
<li><a href="health.php">Health Links</a></li>
</ul>
</li>

最佳答案

试试这个。

.navbar .navbar-nav > li.open > a:hover,
.navbar .navbar-nav > li.open > a:focus {
background-color: teal;
color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>

</button> <a class="navbar-brand" href="#">Brand</a>

</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">Link <span class="sr-only">(current)</span></a>

</li>
<li><a href="#">Link</a>

</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>

<ul class="dropdown-menu">
<li><a href="#">Action</a>

</li>
<li><a href="#">Another action</a>

</li>
<li><a href="#">Something else here</a>

</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

关于css - 单击时如何更改 Bootstrap 导航栏下拉菜单的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31628565/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com