2
Use Bootstrap and it has the following classes for tables:
.table
.table-striped
.table-bordered
.table-hover
.table-condensed
In my application I have several tables. For easy maintenance, I created the class .tabela
and used jQuery to add the classes I want:
jQuery.ready(function() {
$(".tabela")
.addClass("table table-striped table-bordered");
});
So I can easily modify all the application tables by editing only the above section, if you want to add/remove these classes from Bootstrap.
My question is whether there would be a way to use CSS to incorporate these classes into the class .tabela
. I think this would be better practice than using Javascript.
I don’t understand the need to have multiple classes if in the end you’re going to add them all to the same table. Add everything in the same class and delete what is common.
– Filipe Moraes
@Filipe It turns out that these classes are defined by the framework Bootstrap and not by me. I don’t know if it would be a good idea to edit his source code.
– user7261
Don’t edit the source code, make a new css and put your edits there, so you keep the framework intact. What you want to do, I think is not possible with CSS.
– Filipe Moraes
I believe that the way you did it is the best way (using JS), without changing the css of the framework. There is no inheritance in CSS.
– Filipe Moraes
OK @Filipe, I’ll leave anyway. I think it gets more DRY.
– user7261