我创建了一个bootstrap导航栏,然后我改变了颜色,背景颜色和悬停颜色。问题是,由于我做了这些更改,导航栏不会保持固定状态。我是CSS的新手,我到处搜索一个解决方案,遗憾的是我看起来所说的将navbar-static交换到navbar-fixed,但我已经在我的代码中修改了navbar。请帮忙!
以下是相关的CSS和HTML:
.navbar-custom {
z-index:999999; /* here I fixed an issue where the collapsed navbar showed up underneath the slider under it*/
position: absolute;
background-color: #E46142;
}
.section1 .navbar-custom .container #navbar-collapse .nav.navbar-nav li a{
color: white; /* Here I had to target the text very specifically otherwise the color would not change */
}
.section1 .navbar-custom .container .navbar-header .navbar-brand{
color: white;
}
.section1 .navbar.navbar-custom.navbar-fixed-top .container .navbar-header .navbar-toggle .icon-bar{
background-color: white;
}
ul.nav a:hover { color: #000 !important; }

<div class="section1">
<nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand">Name</a>
</div><!-- End Nav Bar Header -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#">Text1</a></li>
<li><a href="#">Text2</a></li>
<li><a href="#">Text3</a></li>
<li><a href="#">Text4</a></li>
<li><a href="#">Text5</a></li>
</ul>
</div>
</div><!-- End Container -->
</nav>
<!-- End Nav Bar -->
</div>
&#13;
答案 0 :(得分:1)
更改position
或删除此position
.navbar-custom {
z-index:999999; /* here I fixed an issue where the collapsed navbar showed up underneath the slider under it*/
position: fixed;
background-color: #E46142;
}