Bootstrap导航栏背景颜色规则不起作用

时间:2016-10-17 12:13:00

标签: css twitter-bootstrap-3

当我尝试更改导航栏背景颜色时,它会在Google Chrome检查器中显示为灰色。在Google上找不到可行的解决方案。

当我删除navbar-default时会发生变化,但是我没有在较小的屏幕上看到切换图标。

我还尝试将规则应用于navbar-default但结果相同。背景颜色不会改变。

body {
  font-family: "Courier New" ;
}  
.ttposter{
  color:black;
  height:400px;
  width:250px;
}

.navbar-custom {
  background-color:#e74c3c;
  color:#ffffff;
  border-radius:0;
  margin-bottom: 0;
}

.navbar-custom .navbar-nav > li > a {
  color:#fff;
}
.navbar-custom .navbar-nav > .active > a, .navbar-nav > .active >    a:hover, .navbar-nav > .active > a:focus {
  color: #ffffff;
  background-color:transparent;
}

.navbar-custom .navbar-brand {
  color:#eeeeee;
}
.headerImgText{
  color:white;
  margin: 10%;
}

body,html {
  height: 100%;
}
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!--Custom css-->
<link rel="stylesheet" type="text/css" href="CSS/styles.css">
<!--Javascript-->
<script type="text/javascript" src="scripts/movies.js"></script>
<title>Homepage</title>
</head>
<body onload="loadFeaturedMovies()">
  <header>
    <nav class="navbar navbar-default navbar-custom navbar-fixed-top">
      <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="collapsed" 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="#">Notflix</a>
        </div>

        <!-- LINKS -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li><a href="index.html">HOME</a></li>
            <li><a href="movies.html">MOVIES</a></li>
            <li><a href="users.html">USERS</a></li>
            <li><a href="login.html">ACCOUNT</a></li>

          </ul>
          <!-- LOGIN -->
          <form class="navbar-form navbar-right">
            <div class="form-group">
              <input type="text" id="loginUsername" class="form-control" placeholder="username">
              <input type="password" id="loginPassword" class="form-control" placeholder="password">
            </div>
            <button type="submit" onclick="login()" class="btn btn-default">Login</button>
          </form>
        </div>
      </div>
    </nav>
  </header>

2 个答案:

答案 0 :(得分:0)

尝试下面的代码,你只需删除背景图片

.navbar-custom {
    background-image: none;
}

请参阅fiddle此处

答案 1 :(得分:0)

检查您的navbar-header课程。在此之下,您有一个带有 data-toggle =“collapsed”的按钮。将其更改为 data-toggle =“collapse”

如Rahul所示,加上应用css:

.navbar-custom {
    background-image: none;
}

请参阅小提琴:https://jsfiddle.net/DTcHh/26317/