Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing color of Twitter bootstrap Nav-Pills

I'm trying to change the active color (after its clicked it remains twitter's light-blue color) for each tab:

 <ul class="nav nav-pills">    <li class="active"><a href="#tab1" data-toggle="tab">Overview</a></li>    <li><a href="#tab2" data-toggle="tab">Sample</a></li>    <li><a href="#tab3" data-toggle="tab">Sample</a></li>  </ul> 

(How) can I do this in CSS?

like image 482
Elias7 Avatar asked May 12 '12 03:05

Elias7


People also ask

How can I change bootstrap NAV active color?

There are two ways that you can change the font color of the active nav-item. The default font-color is white of the active nav-link in the case of Bootstrap nav-active item. The first-way approach is to use a CSS styling file and changing the nav-item class when clicked.


1 Answers

You can supply your own class to the nav-pills container with your custom color for your active link, that way you can create as many colors as you like without modifying the bootstrap default colors in other sections of your page. Try this:

Markup

<ul class="nav nav-pills red">     <li class="active"><a href="#tab1" data-toggle="tab">Overview</a></li>     <li><a href="#tab2" data-toggle="tab">Sample</a></li>     <li><a href="#tab3" data-toggle="tab">Sample</a></li> </ul> 

And here is the CSS for your custom color:

.red .active a, .red .active a:hover {     background-color: red; } 

Also, if you prefer to replace the default color for the .active item in your nav-pills you can modify the original like so:

.nav-pills > .active > a, .nav-pills > .active > a:hover {     background-color: red; } 
like image 94
Andres Ilich Avatar answered Sep 30 '22 01:09

Andres Ilich