在导航栏上更改背景颜色时遇到问题。

时间:2017-06-28 15:46:31

标签: html css navbar background-color nav

我目前正在制作乐队页面并遇到导航栏问题。我希望导航栏是黑色的,以匹配乐队的标志,但尽管尝试使用我的CSS页面上的所有相关课程,但似乎无法改变背景颜色。

<nav class="navbar navbar-default">
  <div class="container">
    <!-- 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="index_thekatellas.html"> 
          <img src="katellas.jpg">
      </a>
    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-left">
        <li><a href="tour_thekatellas.html">Tour Dates</a></li>
        <li><a href="band_thekatellas.html">Band</a></li>
        <li><a href="music_thekatellas.html">Music</a></li>
      </ul>
</nav>

1 个答案:

答案 0 :(得分:0)

你应该使用

 <nav class="navbar navbar-inverse">

它会使你的导航栏变黑。

默认为白色,因此反转为黑色。     

<!DOCTYPE html>
<html lang="en"> 
<head>
  <title>My exam</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet"  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>
  </div>
</nav>
  
<div class="container">
  <h3>Inverted Navbar</h3>
  <p>An inverted navbar is black instead of gray.</p>
</div>

</body>
</html>