Open RobotHabanera opened 7 years ago
@RobotHabanera
The solution you suggested with MQ inside .button
is fine but remember that you need some pre-
or postprocessor to convert it to valid CSS. And maybe something like https://www.npmjs.com/package/postcss-move-media to optimize the resulting CSS at the end.
Thanks.
I am using sass preprocesor with gulp.
This issue with media queries arose because after reading documentation on this site about generic blocks I understoond that block styling "should not change" but today I thought what about media queries?"
For instance I might have:
<section class="services">
<h2 class="services_heading"></h2>
</section>'''
.services styles might need padding-top:100px in resolution above 1200px, but only padding-top:50px in resolution of 400-500px width, therefore I became confused whether with adding media queries to .services generic block would be "according to the BEM rules" due to the "not changing" nature of generic blocks.
BEM is fine with MQ :)
I have a question concerning styles for generic blocks in BEM (for instance .button) vs Media Queries.
The block in BEM (as documentation says) is supposed to have generic styles which will be applicable to all elements on site, let's say I have a ".button" block...
And my button will have reusable styles like:
The purpose of that generic button is so that if I were to make "another" button, say "welcome button" with different styles I can write modificator button--welcome which will only add additional styles to .button which at the end will look like this:
This is where Media Queries PROBLEM comes in. Padding defined in my generic .button can be different for different media queries (I am using border-box so padding are internal styles for .button). For instance padding for max-width:480px can be padding: 10px 5px; Does it mean that I should NOT include padding in my generic .button block because .button will no longer be generic? Or, I can do something like this (but I wonder whether it is valid BEM way):
Also, I've seen some generic .button blocks with the following code:
The issue of generic block styles vs media queries arises in the case of border width, line-height which can be different for different media queries.
I've seen the documentation about external geometry/positioning, but padding is not external geometry: https://en.bem.info/methodology/css/#external-geometry-and-positioning
My issue here is different.