Answer the question
In order to leave comments, you need to log in
Grouping media queries breaks the responsiveness of a BEM element?
I write media not separately at the end of the document, but in each class (where it is needed) + I use BEM
This type of constructions are obtained
// блок карточки товаров
.contain
display: flex
flex-wrap: wrap
&__card
width: 100% / 6
@media (max-width: 62.5em)
width: 100% / 3
&_big
width: 100%
.contain {
display: flex;
flex-wrap: wrap;
}
.contain__card {
width: 100% / 6;
}
.contain__card_big {
width: 100%;
}
@media (max-width: 62.5em) {
.contain__card {
width: 100% / 3;
}
}
Answer the question
In order to leave comments, you need to log in
The adaptive breaks because all these plugins group and write media at the end of your file, thereby interrupting all modifiers.
There is no correct way, but I prefer to define one rule for a single selector first, and place the definitions of any changes to that rule (for example, changes inside media queries) immediately after it. This way, I don't have to search through separate blocks of code to find a declaration related to a particular selector.
It would seem quite reasonable to oppose the aforementioned technology because of its verbosity. Is the file size alone a good enough reason not to write media queries this way? After all, no one wants to have a bloated CSS file to serve their needs. But you need to reckon with the simple fact that gzip compression, which must be subjected to all possible resources on your server, reduces the difference to completely negligible amounts.
Here's another, read: https://benfrain.com/inline-or-combined-media-quer...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question