我试过这个解决方案,它似乎不工作:navbar color in Twitter Bootstrap
任何其他解决方案?我已经尝试了自定义的引导包,但我很远的发展,我可以做一个这样的开关。
码:
.navbar-inner { background-color: #2c2c2c; /* fallback color,place your own */ /* Gradients for modern browsers,replace as you see fit */ background-image: -moz-linear-gradient(top,#333333,#222222); background-image: -ms-linear-gradient(top,#222222); background-image: -webkit-gradient(linear,0 0,0 100%,from(#333333),to(#222222)); background-image: -webkit-linear-gradient(top,#222222); background-image: -o-linear-gradient(top,#222222); background-image: linear-gradient(top,#222222); background-repeat: repeat-x; /* IE8-9 gradient filter */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);}
解决方法
css属性按特定顺序应用
> background-color(由所有网络浏览器识别)
>供应商前缀-moz,-ms,-webkit,-o(用于提供特定的Web浏览器)
>标准(但尚未实现)
使用Chrome的boostrap.css中的背景颜色覆盖示例:
background-color:#ffffff;已经被background-color替换:#eab92d直接进入boostrap.css(它不推荐,但它只是为了说明点)。
background-color:#EAB92D首先应用
线性梯度和-ms线性梯度被忽略
-webkit-gradient cover background:#EAB92D(回到默认渐变)
-webkit-linear-gradient覆盖-webkit-gradient
线性梯度和线性梯度被忽略
将.navbar-inner的颜色从colorzilla中更改
您可以轻松地使用colorzilla创建跨浏览器渐变
创建< style>标记在< head>后调用bootstrap.css。
然后复制由colorzilla生成的css在.navbar-inner {}里面的< style>标签。
.navbar-inner { background: #eab92d; /* Old browsers */ /* IE9 SVG,needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VhYjkyZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjNzk4MTAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top,#eab92d 0%,#c79810 100%); /* FF3.6+ */ background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#eab92d),color-stop(100%,#c79810)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top,#c79810 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top,#c79810 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top,#c79810 100%); /* IE10+ */ background: linear-gradient(to bottom,#c79810 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eab92d',endColorstr='#c79810',GradientType=0 ); /* IE6-8 */ }
由colorzilla生成的css会覆盖boostrap.css中的所有css属性,如下所示
改变’.navbar-inner’是不够的,只有其他位需要改变。
.navbar .btn-navbar(当宽度<768px时打开菜单的按钮)与.navbar-inner共享相同的属性
.navbar-inner,.navbar .btn-navbar { background: #eab92d; /* Old browsers */ /* IE9 SVG,needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VhYjkyZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjNzk4MTAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top,#c79810 100%); /* FF3.6+ */ background: -webkit-gradient(linear,Safari4+ */ background: -webkit-linear-gradient(top,Safari5.1+ */ background: -o-linear-gradient(top,#c79810 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top,#c79810 100%); /* IE10+ */ background: linear-gradient(to bottom,#c79810 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eab92d',GradientType=0 ); /* IE6-8 */ }
.divider-vertical(垂直分隔符)使用渐变中使用的相同颜色
.navbar .divider-vertical { background-color: #c79810; border-right: 1px solid #eab92d; }
.navbar .nav .active > a,.navbar .nav .active > a:hover { background-color: #c79810; }
菜单上的链接的颜色也需要更改,在这种情况下,从渐变的公平颜色到白色的75%。
.navbar .nav > li > a { color: #f9ed9d; }
最后是.brand的颜色,在这种情况下50%从公平的颜色渐变到白色。
.navbar-fixed-top .brand { color: #634c08;color: #f4dc87; }
:悬停颜色的链接尚未更改bu可以用:
.navbar .nav > li > a:hover {color:white;}
与活动链接的颜色相同
.navbar .nav .active > a,.navbar .nav .active > a:hover {color:white;}