Twitter Bootstrap

Status
Not open for further replies.

mudboy

Ars Legatus Legionis
17,501
Subscriptor
I'm playing around with Bootstrap and really like it conceptually, but my problem is this. I want to change colors, etc., without changing the base CSS, but it doesn't seem tailored to that. Bootstrap does include a method for customizing the CSS via web-entered values that get written to the CSS file when it gets packed and downloaded if you want, but I'd like to use bootstrap across a number of web sites that all have different color schemes, so I don't want to customize bootstrap.css.

When I try to override Bootstrap CSS rules via a local style block, some selectors, such as BODY, work, but others, such as .navbar-inner (I'm trying to change the background color for the top nav element) don't... even when I use !important. Am I missing something?

Pete
 
My guess is that you've missed that Bootstrap's navbar color is defined by a gradient in a "background-image" attribute, which overrides "background-color".

Here's the style in bootstrap's code:

Code:
.navbar-inner {
  background-color: #fafafa;
  background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2));
  background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2);
  background-image: -o-linear-gradient(top, #ffffff, #f2f2f2);
  background-image: linear-gradient(to bottom, #ffffff, #f2f2f2);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0);
}

The simplest way to set your own background color would be to use a rule like this:

Code:
.navbar-inner {
  background: #d00;
  filter: none;
}

The shorthand "background" redefines both background-color and background-image and more.

If you still want a gradient you can just copy the whole block above and set your own color values on each line.

If you are using the "navbar-inverse" class in the html, then you need to override the ".navbar-inverse .navbar-inner" rule because it's more specific and take precedence to a simple ".navbar-inner". So like this:

Code:
.navbar-inverse .navbar-inner {
  background: #d00;
  filter: none;
}
 

wiesson

Seniorius Lurkius
4
The question is - why you dont want to change the bootstrap css? I think it is much better to reduce the file-size of the css. On the other hand, it is much easier to switch to a new version of bootstrap, because you dont have to change the new versions files...

If you know the color, just put em in the color-field http://twitter.github.com/bootstrap/cus ... #variables (@linkColor)
 
Status
Not open for further replies.