Bootstrap导航栏下拉样式

时间:2015-11-12 00:06:34

标签: css twitter-bootstrap drop-down-menu navbar

如何更改导航栏上标记栏的标记颜色?我使用了navbar generator,但它有一个错误,并且没有为所需的颜色生成所提到的css代码。这是图片:

enter image description here

这是我目前的css覆盖:

.dropdown-menu { background-color: #3E968A}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus, .dropdown-menu > .active > a:hover { background-color: #42CBAD}
.dropdown-menu>li>a { color: #EEF9FA}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { color: #1D2C43}
.navbar-inverse .navbar-nav>.dropdown>a .caret { border-top-color: #1D2C43}
.navbar-inverse .navbar-nav>.dropdown>a:hover .caret, .dropdown-menu > .active > a { border-top-color: #486972}
.navbar-inverse .navbar-nav>.dropdown>a .caret { border-bottom-color: #1D2C43}
.navbar-inverse .navbar-nav>.dropdown>a:hover .caret { border-bottom-color: #486972}
.navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus { color: #EEF9FA}

1 个答案:

答案 0 :(得分:0)

这就是您尝试做的事情,如果不是,它应该可以帮助您将所需的样式应用到navbar

你还应该查看这篇文章> Change navbar color in Twitter Bootstrap 3以及帖子

中引用的此链接(TWBSColor

请参阅工作代码段。



.navbar.navbar-inverse {
  background-color: #3e968a;
}
.navbar.navbar-inverse .navbar-nav > li > a {
  background-color: #3e968a;
  color: #1d2c43;
}
.navbar.navbar-inverse .navbar-nav > li > a:hover {
  color: #42cbad;
}
.navbar.navbar-inverse .navbar-nav > .active,
.navbar.navbar-inverse .navbar-nav > .active > a,
.navbar.navbar-inverse .navbar-nav > .active > a:hover,
.navbar.navbar-inverse .navbar-nav > .active > a:focus {
  background-color: #486972;
  color: #eef9fa;
}
.navbar.navbar-inverse .dropdown-menu {
  background-color: #3e968a;
}
.navbar.navbar-inverse .dropdown-menu > li > a {
  color: #eef9fa;
}
.navbar.navbar-inverse .dropdown-menu > li > a:hover,
.navbar.navbar-inverse .dropdown-menu>li>a:focus {
  background-color: #42cbad;
  color: #1d2c43;
}
.navbar.navbar-inverse .navbar-nav li.dropdown.open > .dropdown-toggle,
.navbar.navbar-inverse .navbar-nav li.dropdown.active > .dropdown-toggle,
.navbar.navbar-inverse .navbar-nav li.dropdown.open.active > .dropdown-toggle {
  background: #486972;
  color: #eef9fa;
}
.navbar.navbar-inverse .navbar-nav>.dropdown>a:hover .caret {
  border-bottom-color: #486972;
}
.navbar.navbar-inverse .navbar-brand {
  color: #1d2c43;
}

<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-inverse navbar-static-top">
  <div class="container-fluid">
    <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="#">Brand</a>

    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a>

        </li>
        <li><a href="#">Link</a>

        </li>
        <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>

          <ul class="dropdown-menu">
            <li><a href="#">Action</a>

            </li>
            <li><a href="#">Another action</a>

            </li>
            <li><a href="#">Something else here</a>

            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a>

            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a>

            </li>
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a>

        </li>
        <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>

          <ul class="dropdown-menu">
            <li><a href="#">Action</a>

            </li>
            <li><a href="#">Another action</a>

            </li>
            <li><a href="#">Something else here</a>

            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a>

            </li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>
&#13;
&#13;
&#13;