sass code style with media queries -


i'm doing code review sass code , came across using media queries inside code. practice? there better alternatives writing code?

.col-md-push-8 {     padding-top: 1.5em;     .btn {         &.btn-block {             border: none;             background-color: $footer-button;             margin: 1em 0 .5em;             width: 100%;             padding: 7px 10px;             border-radius: 8px;             &:hover {                 background-color: $footer-button-hover;             }             @media (min-width: $screen-md-min) {                 color: #025191;                 &:hover .media span p.media-heading {                     color: #0070ca;                 }             }         }     } } 

note: code illustration purpose , not shown here.

i think way fine if you're using sass >= 3.2 (was buggy before).

just 1 thing define media queries breakpoints more globally create mixin purpose re-use on each element need responsive.

this way when have change let's min breakpoint, add or change media min-width max-width, don't have everywhere.

some little example assuming have defined $screen-md-min , $screen-md-mid :

@mixin custom-media($size) {      @if ($size == $small) {          @media (min-width: $screen-md-min) { @content; }     }     @else if ($size == $middle) {          @media (min-width: $screen-md-mid) { @content; }     } } 

and call :

.btn {     &.btn-block {         ...         @include custom-media($small) {             color: #025191;             &:hover .media span p.media-heading {                 color: #0070ca;             }         }     } } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -