If you want everything to be div1
automatically behave as col-md12
, only with CSS, no putting in HTML does not have an obvious way without repeating the instructions.
What you can do is use tools like LESS, that has the mixins which compose several classes, but only work if he has access to the original files to produce a result.
Now, if you can adjust the HTML, you can add several classes in a single element by separating with spaces:
<div class="col-md12 div1 outrasclasses">
There, if you want a DIV to work only with a certain combination, you can use more than one class in defining the characteristics:
.col-md12.div1{
background: -webkit-linear-gradient(top, #088fad 20%, #00d5ff 100%);
}
See below that the red background only acts in cases where the two classes are defined, but the bold
works in both with class div1
.
.div1{
font-weight:bold;
}
.col-md12.div1{
background: red;
}
<div class="div1">DIV A</div>
<div class="col-md12">DIV B</div>
<div class="col-md12 div1">DIV C</div>
This way I already knew, I thought for example I had a code with several Divs with class col-Md-12 for example, it is wanted that all inherited the attribute of div1. But thank you @Bacco
– Fabio Souza
@Fabiosouza but in this case, nothing prevents you from putting a definition . col-Md-12 in your CSS as well. There will be worth the things of both.
– Bacco