简体   繁体   中英

Changing color for navbar

How can I make the entire navbar black ? In this picture http://prntscr.com/cvgvxj you can see that there are white borders and I can't figure out how to remove them/ make them black .

li:hover {
    background-color: white;
}
body {
    background-color: black;
}
.meniu {
    background-color: black;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Metal</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/stil.css">
    </head>
    <body>
        <script src="js/bootstrap.min.js" ></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src="J/js/collapse.js"></script>
        <script src="J/js/dropdown.js"></script>
        <script src="J/js/button.js"></script>
<nav class="meniu navbar navbar-default">
  <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>
    </div>


    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
     <ul class="nav navbar-nav">
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        </ul> 
    </div>
  </div>
</nav>
    </body>
</html>

To change the background colour of the navigation bar itself, add this to the .nav class:

background-color:#002d60;

.

Actually border-color is the main issue; see DEMO . I also comment out where I have change see the css part. And I make a html structure for you as a suggestion place all css link you have inside head tag <head> and before the body tag all script tag you need to include.
[NB: Don't use the !important part I used in css. I used !important because I overwrite the bootstrap css in same page to get snippet view. Read this When Using !important

 .meniu { background: black !important; border-color:black !important; /*Set the main nav border color black..Don't Use !important in your custom.css file*/ border-radius:0 !important; /*By default it's 4px I change this coz on screen(>768px) It makes a border with 4px radius.. So the corners gets some white space..Don't Use !important in your custom.css file*/ } .navbar-default .navbar-collapse{ border-color:black !important; /*For Mobile Menu collapse background color black... Don't Use !important in your custom.css file*/ } .navbar-nav li:hover { background-color: white !important; /*Don't Use !important in your custom.css file*/ } 
 <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body> <nav class="meniu navbar navbar-default"> <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> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div> </div> </nav> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </body> 

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