Answer the question
In order to leave comments, you need to log in
Should I write a new css class, or write the path to a specific div?
So I'm currently typing on Bootstrap 3, and there is a need to design some buttons in my own way (backgrounds, hoovers, etc.). Such a question should be written like this:
Example 1 (just adding a new class) :
HTML
<div class="container">
<div class="btn btn-primary bg_red"></div>
</div>
.bg_red{
background-color:red;
}
<div id="btn_red" class="container">
<div class="btn btn-primary"></div>
</div>
#btn_red>.btn{
background-color:red;
}
html>.container>[class="btn btn-primary"] ( прописать так )
html>.container>.btn ( или прописать так )
html .container .btn { ( или прописать так, когда надо изменить все btn )
background-color:red;
}
html .container .row .some_class .btn { ... }
Answer the question
In order to leave comments, you need to log in
In general, you surprised me now with both options, as for me, they are both wrong. In general, a long time ago there is such a thing as customized bootstrap
Add classes, learn LESS/SASS. With them, this is done in 2 seconds.
I do the same as you...
...only I create a new element if it is very different from the others or I work on a standard boot and I don't really need to remake it for myself:
.btn-offer, btn-callback
...and so I connected the preprocessor and forgot about these problems by overwriting the standard classes.
But in your case - the first option.
BEM adherents, is bg_red a modifier in this case?
if you use 1 example, then the new style should prescribe all the classes of the block
.btn.btn-primary.bg_red {
..style here
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question