If you want everything div1
to automatically behave like col-md12
, only with CSS, without in HTML does not have an obvious way without repeating the instructions.
What you can do is use tools like LESS , which has the mixins that compose various classes , but only work if it has access to the original files to produce a result.
Now, if you can adjust HTML, you can add multiple classes to the same element by separating with spaces:
<div class="col-md12 div1 outrasclasses">
Then, if you want a DIV to work only with a particular 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 both classes are defined, but bold
works on 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>