我已經搜查了淨一種方式來覆蓋白手起家CSS,但尚未有它爲我工作。我試圖更改默認navbar
顏色,而無需編輯bootstrap.css
文件。
我試圖把在頭下面裝bootstrap.css
後:麻煩重寫引導CSS
.navbar-inner {
background-color: #006633;
background-image: -mox-linear-gradient(top, #006633, #006633);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#006633), to(#006633));
background-image: -webkit-linear-gradient(top, #006633, #006633);
background-image: -o-linear-gradient(top, #006633, #006633);
background-image: linear-gradient(to bottom, #006633, #006633);
border-color: #006633;
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff006633', endColorstr='#ff006633', GradientType=0);
}
這沒有工作,所以我試圖把它放在自己的CSS文件,然後加載一個樣式像這樣:
bootstrapOverload的.css
.navbar-inner {
background-color: #006633;
background-image: -mox-linear-gradient(top, #006633, #006633);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#006633), to(#006633));
background-image: -webkit-linear-gradient(top, #006633, #006633);
background-image: -o-linear-gradient(top, #006633, #006633);
background-image: linear-gradient(to bottom, #006633, #006633);
border-color: #006633;
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff006633', endColorstr='#ff006633', GradientType=0);
}
_Layout.cshtml
<link rel="stylesheet" href="Content/bootstrap.css">
<link rel="stylesheet" href="Content/bootstrapOverload.css">
如果沒有工作,我嘗試添加自定義的類元素
_Layout.cshtml
<div class="navbar-inner navbar-override"> <!-- added navbar-override -->
bootstrapOverload.css
.navbar-override {
background-color: #006633;
background-image: -mox-linear-gradient(top, #006633, #006633);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#006633), to(#006633));
background-image: -webkit-linear-gradient(top, #006633, #006633);
background-image: -o-linear-gradient(top, #006633, #006633);
background-image: linear-gradient(to bottom, #006633, #006633);
border-color: #006633;
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff006633', endColorstr='#ff006633', GradientType=0);
}
上午我做錯了什麼?如果可能的話,我會很樂意學習如何以正確的方式做到這一點。
除了這個鏈接下面的答案http://www.nzwhost.com/article/understanding-css-hierarchy可能有幫助 –
這與[在twitter bootstrap 2 0 4中更改導航欄顏色]非常相似(http://stackoverflow.com/questions/11196638/change-navbar-color-in-twitter-bootstrap- 2-0-4),它有一個非常全面的解決方案。 – everette