G
G
gawozi2015-10-05 20:15:37
css
gawozi, 2015-10-05 20:15:37

How to assign another class to an element with style in stylesheets?

For example
<div class="col"></div>

.col{
  background:#222;
  /* а тут бы как то хитро добавть уже ранее описаный стиль например от бутстрапа col-md-12*/
}

Here is some method to do it. Is there such a thing in CSS?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Inchin ☢, 2015-10-05
@In4in

You can attach several classes to each element, listing them separated by a space:

.one{
   color: red;
}

.two{
   background: tomato;
}

B
Boris Shepelev, 2015-10-05
@bshepelev

You can assign a style name (class) multiple times both in one element and in different ones! The whole point here is in the style hierarchy (priority)!
Those. if the table has both class and style assigned at the same time: table class="name" style="margin:10px 0;" ...
then class=name styles are applied and then style="..." are completed.

I
isour, 2015-10-06
@isour

this can be done in less or scss, something like this:

.col{
  background:#222;
  .yourClassCss;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question