very nice question, and I think this deserves a whole topic, and this answer contributes to all things @Unbranded has shared.
I don't think there's a right or wrong here when it comes to the decision between which one is better or best practice. Sticking to one doesn't mean it's all correct, it's all about the approach the Styling guy get used to, and the most important part is how it was used, make or break is all laying here.
I guess you've already known and familiar with the final compiled CSS of those 2 methods, of course the final bundle size will also be a consideration factor in term of optimizing.
This is where Method 2 seems to lose its point.
Method 2 SCSS:
.container {
width: 100%;
@media screen and (min-width: 768px) {
width: 50%;
}
&.red {
@media screen and (min-width: 768px) {
background: red;
width: 75%;
}
}
}
and this is how the above CSS will be compiled, you clearly might see the duplicated string. Scaling up to a real project, this will likely be a thing to consider.
Method 2 CSS:
.container { width: 100%; }
@media screen and (min-width: 768px) {
.container {
width: 50%;
}
}
@media screen and (min-width: 768px) {
.container.red {
background: red;
width: 75%;
}
}
M1 you will mostly see in old projects, might be back to before 2015, and probably each responsive query will be in a separate file. For example:
responsive.mobile.scss
@media screen and (max-width: 768px) {
// All the stuff
}
responsive.tablet.scss
@media screen and (min-width: 768px) and (max-width: 1024px) {
// All the stuff
}
In the past, I've dealt with a project where responsive thing like this becomes a nightmare, when you have like 4 responsive queries (plus, with retina or portrait / landscape it its own place). You've got big balls maintaining a project like this, where you won't know one change might affect the others, and for some reason your client changes his mind. In a scenario like he also wants the styling for mobile applying for portrait tablet, I believe you know where this leads to.
So, M2 saves the day.
In the modern era of web application, where things get "component-ed", I think M1 was no longer helpful, and for some reason you will see a lot of FE tutorials coming up with M2, the reason is simple. It's clean, and straight to the point. Forget about switching between responsive context, this method proves it helpfulness where FE guys adapt the way he styles.
METHOD 2 with the newbie/junior guy
And because of its simple, M2 becomes something familiar until its purpose gets wrong.
Actually, M1 is about having the style in multi places/files. Each responsive styling lies in its own file, and M2 is about styling for a component, where all the styling lies in one single place.
Think of this scenario, this also becomes a nightmare for maintaining:
Method 2 with Bad mixing of Responsive Query
.container {
width: 100%;
.button {
background: red;
@media screen and (min-width: 768px) {
background: green;
}
}
&.red {
background: red;
@media screen and (min-width: 768px) {
background: darken(red, .15);
width: 75%;
}
}
@media screen and (min-width: 768px) {
width: 50%;
}
}
Method 2 with Good mixing of Responsive Query
.container {
width: 100%;
.button {
background: red;
}
&.red {
background: red;
}
@media screen and (min-width: 768px) {
width: 50%;
.button {
background: green;
}
&.red {
background: darken(red, .15);
width: 75%;
}
}
}
The first block is what someone new would try M2 at first attempts, not recognizing the final result. The example just comes with one single media query, think of multi queries.
Of course the second one is someone who has experienced styling with M2 , it's clear and easier to maintain.
Personally, I'm the guy who used to work with M1, now completely switching to M2 in my works. Most of my project styling comes at a ratio of 7:3, where 70% M2 is applied for specific components, and 30% M1 is applied globally / generic styling. I found this works for the best. Not mentioning that now we've also had JCSS or styled-components come into the game.
As mentioned, your team leader might be a guy who used to seeing CSS in Method 1, and he had his points. And this totally depends on your particular project scope, which method might works better than the other.