I just converted my css project over to scss and now that I am flipping back and forth between various partials I am wondering if it would just be easier to write my @media rules for an element right in the file below the corresponding selector, rather than at the bottom in a specific @media file?
For example the standard css method:
#header {
/* css style */
}
#nav{
/* css style */
}
.nav-container {
/* css style */
}
.
. 700+ lines of css...
.
@media screen and (max-width: 900px) {
#header {
/* new css style */
}
#nav{
/* new css style */
}
}
@media-queries screen and (max-width: 600px)*/
.nav-container {
/* new css style */
}
}
Versus what I would prefer to write in Scss partials:
_header.scss
#header {
/* css style */
}
// HEADER @MEDIA-QUERIES
@media-queries screen and (max-width: 600px)
/* new header css style */
@media-queries screen and (max-width: 400px)*/
/* new header css style */
_nav.scss
#nav {
/* css style */
}
.nav-container {
/* css style */
}
// NAV @MEDIA-QUERIES
@media-queries screen and (max-width: 600px)
/* new nav css style */
@media-queries screen and (max-width: 400px)*/
/* new nav css style */
/* new nav-container css style */
Is this second method an acceptable practice? Why or why not?
A similar question was asked 5years ago but only ever answered by a robot with advice that didn't seem very decisive. CSS media queries placement