Twitter Bootstrap offers classes to color table rows like so:
<tr class="success">
I like the color choice and the class naming. Now what I would like to do, is to re-use these classes and apply them on table cells, too. Obviously, I could define my own classes with the same colors and be done with it.
But is there a shorthand in CSS. LESS, to let the td
inherit the classes?
You can override the default css rules with this:
!important
is needed as bootstrap actually colours the cells individually (afaik it's not possible to just apply background-color to a tr). I couldn't find any colour variables in my version of bootstrap but that's the basic idea anyway.With the current version of Bootstrap (3.3.7), it is possible to color a single cell of a table like so:
<td class = 'text-center col-md-4 success'>
Updated html for the newer bootstrap
Bottom line is that you'll have to write a new css rule for that.
Depending on which bundle of Twitter Bootstrap you're using, you should have variables for the various colours.
Try something like:
Surely there's a way to use
extend
or the LESS equivalent to avoid repeating the same styling.With less you can set it up like this;
That did the trick for me.