gpt4 book ai didi

javascript - 更改折叠的导航栏列表背景颜色

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

所以,我遇到了这个问题,当我折叠我的导航栏(它变成了切换按钮)并打开列表时,背景颜色是透明的。由于我为导航栏使用了透明背景,这应该是预料之中的,但是当我打开内容时,它与屏幕上的文本重叠,变得凌乱和丑陋。我想将 div 的背景颜色设置为在我折叠到移动版本( Bootstrap )时更改,有什么办法可以做到吗?

这是我的代码:

.navbar-right .dropdown-menu {
right: 0;
left: auto;
top: 60px;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: #4f82e9;
background-color: transparent;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #4f82e9;
background-color: transparent;
}
#offcanvas .navbar-nav > li:last-child > a {
border-bottom-color: transparent !important;
}
@media (min-width: 768px) {
.navbar-toggle {
display: none;
}
}
.navbar-default .navbar-toggle {
position: relative;
float: right;
padding: 5px 5px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
background-color: transparent;
background-image: none;
border: 1px solid transparent !important;
border-radius: 2px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-fixed-top js-navbar-top js-toggleClass">

<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>

<span class="icon-bar"></span>
<span class="icon-bar"></span>

</button>
<a class="navbar-brand page-scroll" href="#page-top">ABA Arquitetura</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 navbar-right ">

</li>
<li>
<a class="page-scroll" href="#lancamentos">Lançamentos</a>
</li>
<li>
<a class="page-scroll" href="#services">Serviços</a>
</li>
<li>
<a class="page-scroll" href="#portfolio">Portfolio</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contato</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

最佳答案

这是您要找的吗?

将此添加到您的 CSS:

@media (max-width: 767px) {
.navbar-collapse
{
background-color:#FA0;
}
}

我曾经用一个 jsfiddle 得出这个结论:https://jsfiddle.net/7gvg6mxp/

关于javascript - 更改折叠的导航栏列表背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32147082/

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