AgeDeO
AgeDeO

Reputation: 3157

How to reference another selector in css

I'm using bootstrap in a new project of mine and when I create a table I need to type this code <table class="table table-responsive table-striped table-bordered table-hover">

I would like to just use <table class="table"> and add the rest automatically.

I was hoping this could be done with css like the following:

.table {
    add .table-responsive;
    add .table-striped;
    etc...
}

Is something like that possible, if not, what should you do to solve this?

Upvotes: 0

Views: 44

Answers (1)

Tien Nguyen
Tien Nguyen

Reputation: 599

it is not possible in pure css. if you use some css templater language like Sass, you could use @extend for this purpose. however in fact it will just produce css with .table class and copy-pasted css rules of another classes.

--

with @torazaburo remark. actually it will produce

.another-class, .table { another-class-rules } 

rather than

.table { another-class-rules }

Upvotes: 1

Related Questions