我已经搜查了净一种方式来覆盖白手起家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