Bootstrap 导航栏背景颜色没有改变

jos*_*pj1 2 html css twitter-bootstrap

我正在为我的网站使用引导程序导航栏。如果我想更改导航栏的背景颜色,我可以使用:

<!-- Navbar -->
<nav class="navbar navbar-default" role="navigation" >

    <div class="container-fluid" style="background-color:#000000">

       <p>hi</p>

    </div>

</nav>
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试在外部工作表中使用 css 使用

.nav_backcolor {
   background-color:#000000;
}
Run Code Online (Sandbox Code Playgroud)

或使用覆盖样式表中的引导程序类

.navbar-default {

background-color:#000000;

}
Run Code Online (Sandbox Code Playgroud)

并添加类

<!-- Navbar -->
<nav class="navbar navbar-default nav_backcolor" role="navigation" >

<div class="container-fluid">

   <p>hi</p>

</div>

</nav>
Run Code Online (Sandbox Code Playgroud)

它不起作用。请问有什么帮助吗?

toh*_*d87 5

我相信 Bootstrap 使用linear-gradient导致问题的背景图像,尝试只设置主背景属性:

.navbar-default {
  background: #000000;
}
Run Code Online (Sandbox Code Playgroud)

  • 你可以用`background-image: none;`来实现。 (2认同)