2015-07-19 36 views
1

在第一个示例中,我用background-colornavbar的背景颜色更改为orangered,但它不起作用,在下一个示例中,我仅使用了background来更改颜色,现在它正在工作,原因是什么对于这种行为?bootstrap navbar background-color不起作用,但后台工作?

第一示例

@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"); 
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"); 

.navbar{ 
    background-color: orangered; 
    color: white; 
    line-height: 50px; 
}
<div class="navbar navbar-inverse"> 
    "background-color: orangered;" is not working. 
</div>

接着〔实施例

@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"); 
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"); 

.navbar{ 
    background: orangered; 
    color: white; 
    line-height: 50px; 
}
<div class="navbar navbar-inverse"> 
    "background: orangered;" is working. 
</div>

回答

7

当您使用background-color原始类别.navbar-inversebackground-image: linear-gradient(to bottom,#3c3c3c 0,#222 100%)在css中占据上风。

enter image description here

在导航栏的CSS添加background-image: none;取消它

CSS

.navbar { 
    background-color: orangered; 
    color: white; 
    line-height: 50px; 
    background-image: none; 
} 
当您使用 background它取消 background-image CSS所以你看到的颜色

enter image description here

+0

好答案。 :-) – Muhammad