Bootstrap导航栏下拉元素

时间:2015-05-25 13:55:08

标签: html css twitter-bootstrap

我已经生成了一个bootstrap 3导航栏,除了一个我无法弄清楚的用例外,它完美地工作。

当我打开下拉菜单时,导航栏元素变为黑色,即使我还没有定义此行为。

当我检查元素时,我可以看到似乎遵循了以下CSS(我更改了颜色以证明这是违规项目),尽管我认为这是用我的CSS样式写的:

.navbar-nav>.open>a {
background-image: -webkit-linear-gradient(top,#080808 0,#0f0f0f 100%);
background-image: -o-linear-gradient(top,#080808 0,#0f0f0f 100%);
background-image: -webkit-gradient(linear,left top,left   bottom,from(#080808),to(#0f0f0f));
background-image: linear-gradient(to bottom,#FFFFFF 0,#FFFFFF 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);
background-repeat: repeat-x;
-webkit-box-shadow: inset 0 3px 9px rgba(0,0,0,.25);
box-shadow: inset 0 3px 9px rgba(0,0,0,.25);
}

如何删除此样式,以使导航栏元素的背景颜色保持我想要的颜色?

我的HTML:

 <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
    <div class="container">           
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <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="#">My brand here</a>
        </div>           
        <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="#">Item One</a>
                </li>
                 <li class="dropdown">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle">Item Two <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Drop down item </a></li>
                        <li><a href="#">Drop down item </a></li>
                        <li><a href="#">Drop down item </a></li>
                        <li><a href="#">Drop down item </a></li>                                                       
                    </ul>
                </li>
                 <li class="dropdown">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle">Item three <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Drop down item </a></li>
                        <li><a href="#">Drop down item </a></li>
                        <li><a href="#">Drop down item </a></li>                                                       
                    </ul>
                </li>
                <li>
                    <a href="#">Item four </a>
                </li>
                <li>
                    <a href="#">Item five</a>
                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>

导航栏的CSS样式

 .navbar-inverse { background-color: #F61E99}
    .navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-  nav>li>a:hover, .navbar-inverse .navbar-nav>li>a:focus { background-color: #FFFFFF}
    .navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:hover, .navbar-inverse .navbar-nav>.open>a:focus { background-color: #F61E99}
.dropdown-menu { background-color: #FFFFFF}
.dropdown-menu .open {background-color: #F61E99}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { background-color: #F61E99}
.navbar-inverse { background-image: none; }
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { background-image: none; }
.navbar-inverse { border-color: #F61E99}
.navbar-inverse .navbar-brand { color: #FFFFFF}
.navbar-inverse .navbar-brand:hover { color: #FFFFFF}
.navbar-inverse .navbar-nav>li>a { color: #FFFFFF}
.navbar-inverse .navbar-nav>li>a:hover, .navbar-inverse .navbar-nav>li>a:focus { color: #F61E99}
.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:hover, .navbar-inverse .navbar-nav>.open>a:focus { color: #FFFFFF}
.navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus { color: #FFFFFF}
.dropdown-menu>li>a { color: #333333}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus { color: #FFFFFF}
.navbar-inverse .navbar-nav>.dropdown>a .caret { border-top-color: #999999}
.navbar-inverse .navbar-nav>.dropdown>a:hover .caret { border-top-color: #FFFFFF}
.navbar-inverse .navbar-nav>.dropdown>a .caret { border-bottom-color: #999999}
.navbar-inverse .navbar-nav>.dropdown>a:hover .caret { border-bottom-color: #FFFFFF}

我打开导航栏下拉列表时的行为截图: enter image description here

1 个答案:

答案 0 :(得分:2)

覆盖background-image的{​​{1}}属性。更新您的CSS代码,如下所示。

nav-bar