Using Bootstrap v2.3.2, I am trying to change the default background color for the active tabs. I've tried to set as below, but it doesn't work:
.nav-tabs > .active > a,
.nav-tabs > .active > a:hover,
.nav-tabs > .active > a:focus
{
color: #555555;
background-color: red;
}
Any advice as to why this isn't working, or how to fix it?
To change the color of a sheet tab, right-click the tab, point to Tab Color and pick a color that you want. Tip: Click away from the formatted tab to see the new tab color. If you want to remove the color, right-click the tab, point to Tab Color, and pick No Color.
You can always modify your navigation list through css. Use this css code instead, in that way use you use the a tag to change the color and its background-color. It's improper to use the li tag to set the background only and a tag to set the color of the text.
In the Bootstrap v2.3.2 CSS file, the CSS is as follows for your snippet:
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
color: #555555;
cursor: default;
background-color: #ffffff;
border: 1px solid #dddddd;
border-bottom-color: transparent;
}
Compare this to your CSS snippet as you can see, you are missing the li
selector before .active
selector.
Your CSS is correct however it does not work as the specificity in the Bootstrap CSS is more.
So Just change your code snippet to by increasing specificity:
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus{
color: #555555;
background-color: red;
}
Now your browser when it renders the page will choose your CSS snippet. You can see an example here: http://jsfiddle.net/yyPrg/
You can read up on CSS specificity here: http://css-tricks.com/specifics-on-css-specificity/ and here: http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With