Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navbar color in Twitter Bootstrap

How can I change the background color of the navbar of the Twitter Bootstrap 2.0.2? How can I change color of all the elements of the navbar to reflect the background color?

like image 681
Gattoo Avatar asked Mar 26 '12 09:03

Gattoo


People also ask

How can I change navbar color in bootstrap?

Changing the text color The text color of the navigation bar can be changed using two inbuilt classes: navbar-light: This class will set the color of the text to dark. This is used when using a light background color. navbar-dark: This class will set the color of the text to light.

What color is navbar-dark?

Use navbar-dark for lighter text color (white), or navbar-light for darker text color (black).

How do I add background color to navbar?

Use any of the . bg-color classes to add a background color to the navbar. Tip: Add a white text color to all links in the navbar with the . navbar-dark class, or use the .


1 Answers

You can overwrite the bootstrap colors, including the .navbar-inner class, by targetting it in your own stylesheet as opposed to modifying the bootstrap.css stylesheet, like so:

.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, #333333, #222222);   background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));   background-image: -webkit-linear-gradient(top, #333333, #222222);   background-image: -o-linear-gradient(top, #333333, #222222);   background-image: linear-gradient(top, #333333, #222222);   background-repeat: repeat-x;    /* IE8-9 gradient filter */   filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0); } 

You just have to modify all of those styles with your own and they will get picked up, like something like this for example, where i eliminate all gradient effects and just set a solid black background-color:

.navbar-inner {   background-color: #000; /* background color will be black for all browsers */   background-image: none;   background-repeat: no-repeat;   filter: none; } 

You can take advantage of such tools as the Colorzilla Gradient Editor and create your own gradient colors for all browsers and replace the original colors with your own.

And as i mentioned on the comments, i would not recommend you modifying the bootstrap.css stylesheet directly as all of your changes will be lost once the stylesheet gets updated (current version is v2.0.2) so it is preferred that you include all of your changes inside your own stylesheet, in tandem with the bootstrap.css stylesheet. But remember to overwrite all of the appropriate properties to have consistency across browsers.

like image 148
Andres Ilich Avatar answered Sep 21 '22 02:09

Andres Ilich