A
A
alexandrnevajno12017-07-08 15:46:47
css
alexandrnevajno1, 2017-07-08 15:46:47

Bootstrap is a bad practice to add custom classes/styles to framework elements. How then is it better in my case?

Hello! I heard that it is not desirable to add your own classes to Bootstrap elements - this is a bad practice. For example:
<div class="col-md-3 sub-content"> ...</div>
It's better to do this:

<div class="main">
<div class="col-md-3">
<div class="sub-content">... </div>
</div>
</div>

Is it really better? And why? This results in more divs, and having too many divs is also bad practice.
And further. If neither option, is it better to add STYLES to the Boostrap element? Here:
.main .col-md-3 {
....
}

Or is that bad practice too? What is the best way to do it then?

Answer the question

In order to leave comments, you need to log in

7 answer(s)
W
Welaurs, 2017-07-08
@Welaurs

Good day. And the one who

I heard that it is not desirable to add your own classes to Bootstrap elements - this is a bad practice
spoke gave his arguments or arguments?
Of course, a lot of divs affect readability, but do the constructions given in example 2 improve it?

S
sim3x, 2017-07-08
@sim3x

Use sass/less
ruby.bvision.com/blog/please-stop-embedding-bootst...

B
BB 8, 2017-07-09
@fruity4pie

Best not to use bootsTRAP.
Explore FLEX. It's like a headache pill

S
Sergey Sidorov, 2017-07-13
@serjazz

It's actually bad practice (and debatable in some cases) to override existing bootstrap properties set on specified classes (simply because it changes native behavior and makes it unexpected). A block with already assigned bootstrap classes can be assigned its own classes in cases where these classes extend (and do not overlap (again, this is not always the rule)) a set of properties given to the element.
In general, bad / good is a very vague concept and applying any statement categorically is a mistake, there are different situations and you need to act in accordance with them. There is no single practice in layout, there are many approaches.

I
Ilya, 2017-07-08
@flammerman

And the piling up of classes so that they do not fit in one line on a 1366px screen is this normal?
col-6 col-sm-12 col-md-6 col-lg-4 text-center my-class__part1-ho4y-4tob-bilo-levee-na5px
Use inheritance. Don't torture bootstrap+).

V
Violetta Morozova, 2017-07-14
@vilka_2009

Author: I have never heard of this before.

  • If you think like this, then probably it would be considered bad form to add classes, which then will combine the rules regarding sizes, indents, and styling.
  • There are cases when it is necessary to redefine the column's padding/padding. I think here it is better to add a class to this column, which will be responsible for the internal / external indents.
  • There are cases when it is necessary to style a column. Just because of these same indents (I can’t give an example, the memory is not the same anymore) - add a class to it.
  • After all, the bootstrap grid just helps you not worry about width and padding.
  • I was initially driven into the head that a lot of nesting is bad. No one forbids, but you should try to avoid it.
  • And most importantly, there are too many people in our developer community who come up with all sorts of rules and norms of "behavior". Mostly because they are used to living by the rules. And life is an improvisation.

A
Alexander Pushkarev, 2017-07-08
@AXP-dev

Classes can be added, for more convenient manipulation through js. Well, or to create an additional cascade. But it is better not to use specific properties.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question