简体   繁体   中英

Twitter Bootstrap Change Navbar

I am trying to change the colour of the top navigation bar of a twitter bootstrap page. I am using Twitter Bootstrap 2.3.2

I have tried following this answer exactly with no success: Change navbar color in twitter bootstrap 2.0.4

I have also tried the answer here: navbar color in Twitter Bootstrap

I am linking the bootstrap.min.css and bootstrap-responsive.min.css files above my inline css.

The code for my navbar is

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-targert=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="brand" href='#'>Test</a>
            <div class="nav-collapse collapse">

                <ul class="nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#register">Register</a></li>
                    <li><a href="#about">About</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">List1<b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li class="nav-header">Title</li>
                            <li><a href="#">Item1</a></li>
                            <li><a href="#">Item2</a></li>    
                        </ul>
                    </li>                            
                </ul>


            </div>
        </div>
    </div>
</div>

I have tried all answers from the questions linked above, the latest CSS I am using to override the navbar colour is:

.navbar-inner {
  background-color: red; /* background color will be black for all browsers */
  background-image: none;
  background-repeat: no-repeat;
  filter: none;
}

This doesn't change the colour of the navbar at all. It's still the default colour.

Appreciate any help. Thanks.

Since you are using the .navbar-inverse class, you need to use more specific css. .navbar-inverse .navbar-inner is overriding the coloring for .navbar-inner

Use this css selector:

.navbar-inverse .navbar-inner {
  background-color: red; /* background color will be black for all browsers */
  background-image: none;
  background-repeat: no-repeat;
  filter: none;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM