2017-01-14 83 views
1

我想編輯我的bootstrap導航欄的樣式。但是,例如,我無法編輯顏色和刪除邊框。我想只是將顏色更改爲白色,並將邊框顏色更改爲白色,以及下面的代碼。誰能告訴我我做錯了什麼?如何編輯引導程序導航欄的樣式?

.navbar-default { 
 
    background-color: #ffffff; 
 
    border-color: #ffffff; 
 
} 
 
.navbar-default .navbar-brand { 
 
    color: #292929; 
 
} 
 
.navbar-default .navbar-brand:hover, 
 
.navbar-default .navbar-brand:focus { 
 
    color: #ffd4d4; 
 
} 
 
.navbar-default .navbar-text { 
 
    color: #292929; 
 
} 
 
.navbar-default .navbar-nav > li > a { 
 
    color: #292929; 
 
} 
 
.navbar-default .navbar-nav > li > a:hover, 
 
.navbar-default .navbar-nav > li > a:focus { 
 
    color: #ffd4d4; 
 
} 
 
.navbar-default .navbar-nav > .active > a, 
 
.navbar-default .navbar-nav > .active > a:hover, 
 
.navbar-default .navbar-nav > .active > a:focus { 
 
    color: #ffd4d4; 
 
    background-color: #ffffff; 
 
} 
 
.navbar-default .navbar-nav > .open > a, 
 
.navbar-default .navbar-nav > .open > a:hover, 
 
.navbar-default .navbar-nav > .open > a:focus { 
 
    color: #ffd4d4; 
 
    background-color: #ffffff; 
 
} 
 
.navbar-default .navbar-toggle { 
 
    border-color: #ffffff; 
 
} 
 
.navbar-default .navbar-toggle:hover, 
 
.navbar-default .navbar-toggle:focus { 
 
    background-color: #ffffff; 
 
} 
 
.navbar-default .navbar-toggle .icon-bar { 
 
    background-color: #292929; 
 
} 
 
.navbar-default .navbar-collapse, 
 
.navbar-default .navbar-form { 
 
    border-color: #292929; 
 
} 
 
.navbar-default .navbar-link { 
 
    color: #292929; 
 
} 
 
.navbar-default .navbar-link:hover { 
 
    color: #ffd4d4; 
 
} 
 

 

 
.navbar-brand { 
 
    transform: translateX(-50%); 
 
    left: 50%; 
 
    position: absolute; 
 
} 
 

 
.navbar-nav > li.navbar-left { 
 
    font-family: 'Nunito Sans', sans-serif; 
 
    font-size: 11px; 
 
} 
 

 
.navbar-brand { 
 
    padding: 0px; 
 
} 
 
.navbar-brand>img { 
 
    height: 90%; 
 
    width: auto; 
 
} 
 

 
.banner { 
 
\t width: 100%; 
 
\t /*background-color: #c3d7df;*/ 
 
} 
 

 
.banner-inner { 
 
\t max-width: 1100px; 
 
\t margin: 0 auto; 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
\t <meta charset="utf-8"/> 
 
\t <meta name="viewport" content="width=device=width, initial-scale=1.0"> 
 
\t <title> My Website</title> 
 
\t <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> 
 
\t <link rel="stylesheet" type="text/css" href="style.css" /> 
 
\t <link href="https://fonts.googleapis.com/css?family=Nunito|Nunito+Sans|Playfair+Display" rel="stylesheet"> 
 
\t <!-- Latest compiled and minified CSS --> 
 
\t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
\t <!-- Latest compiled and minified JavaScript --> 
 
\t <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
\t </head> 
 
<body> 
 
\t <header> 
 
\t \t <div class="container"> 
 
    <nav class="navbar navbar-default"> 
 
    <div class="container-fluid"> 
 
     <div class="navbar-header"> 
 
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> 
 
      <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="http://jh.com"><img class= "logo" src="img/logo.png"></a> 
 
     </div> 
 
     <div id="navbar" class="navbar-collapse collapse"> 
 
     <ul class="nav navbar-nav"> 
 
      <li class="navbar-left"><a href="index.html">TRAVEL</a></li> 
 
\t \t <li class="navbar-left"><a href="#"> INSPIRATION</a></li> 
 
\t \t <li class="navbar-left"><a href="#"> PORTFOLIO </a></li> 
 
\t \t <li class="navbar-left"><a href="#"> ABOUT </a></li> 
 
     </ul> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
\t \t <li> <a href="https://www.instagram.com"><i class="fa fa-instagram"></i></a> 
 
\t \t <li> <a href="https://www.pinterest.com"><i class="fa fa-pinterest"></i></a> 
 
\t \t <li> <a href="https://www.facebook.com"><i class="fa fa-facebook"></i></a> 
 
\t \t <li> <a href="https://twitter.com"><i class="fa fa-twitter"></i></a> 
 
\t \t \t \t 
 
\t \t \t \t 
 
     </ul> 
 
     </div> 
 
     <!--/.nav-collapse --> 
 
    </div> 
 
    <!--/.container-fluid --> 
 
    </nav> 
 
</div> 
 
\t </header> 
 
<!---End Header--> 
 
\t <section class="banner"> 
 
\t \t <div class="banner-inner"> 
 
\t \t \t <img class="banner" src="img/background.png"> 
 
\t \t </div> 
 
\t </section> 
 
<!---End Banner--> 
 
</body> 
 
</html>

+0

不要創建具有相同名稱的CSS。創建一些新的類並添加到引導欄中。 –

+0

如果您使用相同的名稱,請使用!重要的CSS屬性。 –

回答

2

這是發生,因爲你的CSS正在被默認引導CSS覆蓋。

您只需進行一項更改。使用.navbar.navbar-default而不是僅僅使用.navbar-default,這會讓您的css偏好超過默認的CSS。

這裏有一個關於CSS具體的好文章:https://css-tricks.com/specifics-on-css-specificity/

.navbar.navbar-default { 
 
    background-color: #ffffff; 
 
    border-color: #ffffff; 
 
} 
 
.navbar.navbar-default .navbar-brand { 
 
    color: #292929; 
 
} 
 
.navbar.navbar-default .navbar-brand:hover, 
 
.navbar.navbar-default .navbar-brand:focus { 
 
    color: #ffd4d4; 
 
} 
 
.navbar.navbar-default .navbar-text { 
 
    color: #292929; 
 
} 
 
.navbar.navbar-default .navbar-nav > li > a { 
 
    color: #292929; 
 
} 
 
.navbar.navbar-default .navbar-nav > li > a:hover, 
 
.navbar.navbar-default .navbar-nav > li > a:focus { 
 
    color: #ffd4d4; 
 
} 
 
.navbar.navbar-default .navbar-nav > .active > a, 
 
.navbar.navbar-default .navbar-nav > .active > a:hover, 
 
.navbar.navbar-default .navbar-nav > .active > a:focus { 
 
    color: #ffd4d4; 
 
    background-color: #ffffff; 
 
} 
 
.navbar.navbar-default .navbar-nav > .open > a, 
 
.navbar.navbar-default .navbar-nav > .open > a:hover, 
 
.navbar.navbar-default .navbar-nav > .open > a:focus { 
 
    color: #ffd4d4; 
 
    background-color: #ffffff; 
 
} 
 
.navbar.navbar-default .navbar-toggle { 
 
    border-color: #ffffff; 
 
} 
 
.navbar.navbar-default .navbar-toggle:hover, 
 
.navbar.navbar-default .navbar-toggle:focus { 
 
    background-color: #ffffff; 
 
} 
 
.navbar.navbar-default .navbar-toggle .icon-bar { 
 
    background-color: #292929; 
 
} 
 
.navbar.navbar-default .navbar-collapse, 
 
.navbar.navbar-default .navbar-form { 
 
    border:none; 
 
} 
 
.navbar.navbar-default .navbar-link { 
 
    color: #292929; 
 
} 
 
.navbar.navbar-default .navbar-link:hover { 
 
    color: #ffd4d4; 
 
} 
 

 

 
.navbar-brand { 
 
    transform: translateX(-50%); 
 
    left: 50%; 
 
    position: absolute; 
 
} 
 

 
.nav.navbar-nav > li.navbar-left { 
 
    font-family: 'Nunito Sans', sans-serif; 
 
    font-size: 11px; 
 
} 
 

 
.navbar-brand { 
 
    padding: 0px; 
 
} 
 
.navbar-brand>img { 
 
    height: 90%; 
 
    width: auto; 
 
} 
 

 
.banner { 
 
\t width: 100%; 
 
\t /*background-color: #c3d7df;*/ 
 
} 
 

 
.banner-inner { 
 
\t max-width: 1100px; 
 
\t margin: 0 auto; 
 
} 
 
@media (min-width:768px) and (max-width:991px){ 
 
    .container.navbar-container { 
 
    width:100%; 
 
    padding:0; 
 
    } 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
\t <meta charset="utf-8"/> 
 
\t <meta name="viewport" content="width=device=width, initial-scale=1.0"> 
 
\t <title> My Website</title> 
 
\t <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> 
 
\t <link rel="stylesheet" type="text/css" href="style.css" /> 
 
\t <link href="https://fonts.googleapis.com/css?family=Nunito|Nunito+Sans|Playfair+Display" rel="stylesheet"> 
 
\t <!-- Latest compiled and minified CSS --> 
 
\t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
\t <!-- Latest compiled and minified JavaScript --> 
 
\t <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
\t </head> 
 
<body> 
 
\t <header> 
 
\t \t <div class="container navbar-container"> 
 
    <nav class="navbar navbar-default"> 
 
    <div class="container-fluid"> 
 
     <div class="navbar-header"> 
 
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> 
 
      <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="http://jh.com"><img class= "logo" src="http://images.financialexpress.com/2015/12/Lead-image.jpg"></a> 
 
     </div> 
 
     <div id="navbar" class="navbar-collapse collapse"> 
 
     <ul class="nav navbar-nav"> 
 
      <li class="navbar-left"><a href="index.html">TRAVEL</a></li> 
 
\t \t <li class="navbar-left"><a href="#"> INSPIRATION</a></li> 
 
\t \t <li class="navbar-left"><a href="#"> PORTFOLIO </a></li> 
 
\t \t <li class="navbar-left"><a href="#"> ABOUT </a></li> 
 
     </ul> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
\t \t <li> <a href="https://www.instagram.com"><i class="fa fa-instagram"></i></a> 
 
\t \t <li> <a href="https://www.pinterest.com"><i class="fa fa-pinterest"></i></a> 
 
\t \t <li> <a href="https://www.facebook.com"><i class="fa fa-facebook"></i></a> 
 
\t \t <li> <a href="https://twitter.com"><i class="fa fa-twitter"></i></a> 
 
\t \t \t \t 
 
\t \t \t \t 
 
     </ul> 
 
     </div> 
 
     <!--/.nav-collapse --> 
 
    </div> 
 
    <!--/.container-fluid --> 
 
    </nav> 
 
</div> 
 
\t </header> 
 
<!---End Header--> 
 
\t <section class="banner"> 
 
\t \t <div class="banner-inner"> 
 
\t \t \t <img class="banner" src="img/background.png"> 
 
\t \t </div> 
 
\t </section> 
 
<!---End Banner--> 
 
</body> 
 
</html>

+0

評論不適合長時間討論;這個對話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/133138/discussion-on-answer-by-kittycat-how-do-i-edit-the-style-of-bootstrap-導航)。 –