css - Grid-Media IN vs OUT -


me , coworker went eternal discussion best way use neat grid-medias.

consider following approuch:

approuch a:

.mydiv {   font-size: 14px;    @include grid-media($somegridvar) {     font-size: 18px;   } } 

then, consider this:

approuch b:

.mydiv {   font-size: 14px; }  @include grid-media($somegridvar) {   .mydiv {     font-size: 18px;   } } 

testing on neat, both approuchs renders same result, not put here because obvious.

my question is: prefer? there "better" approach suggested thoughtbot? there "better" approach suggested someone? there reason use 1 instead of other? matter of style? have use both provide enriched life statement?

what deduced till now:

in approuch a, have several includes of grid media on our pages, making code harder read , more bloated. @ other side, grid media centered in 1 single rule, , same rule not repeated on document each grid media.

in approuch b, have single block of each grid-media each breakpoint, resulting in shorter code, multiplying places element classes appear.

also, if coworker reading this, im looking forward discover way better. (yes, not tell one)

👋 hi!

i’ll preface saying code style team thing. works us, may not work you. above all, consistency , shared understanding matters. don’t spend time in weeds, little details. being said, (thoughtbot) publish our code style guides , prefer syntax (your ‘approach a’):

.mydiv {   font-size: 14px;    @include grid-media($somegridvar) {     font-size: 18px;   } } 

why? mydiv thing you’re styling, not media query itself. encompassing styles relate selector within 1 declaration block provides lot of clarity. having styles affect selector spread out through multiple blocks can become hard decipher.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -