The common way to use media queries is to group all styling for a specific query. Leenull, a colleague of mine, came with the idea to use media queries on a component level. This might make make complex stylesheets easier to maintain.
I wonder what you think of it. Please let me know in the comments. Here's a link to a working example.
.item1 {
background: red;
}
@media (max-width:480px){
.item1 {
background: green;
}
}
.item2 {
background: blue;
}
@media (max-width:480px){
.item2 {
background: yellow;
}
}
.item3 {
background: purple;
}
@media (max-width:480px){
.item3 {
background: papayawhip;
}
}
.item1 {
background: red;
}
.item2 {
background: blue;
}
.item3 {
background: purple;
}
@media (max-width:480px){
.item1 {
background: green;
}
.item2 {
background: yellow;
}
.item3 {
background: papayawhip;
}
}
I don't think this will make stylesheets easier to maintain.
There's a lot of code duplication and you change the maintenance issues from components to media queries: instead of difficulty in finding a specific compontent (search for ".item1 {") this makes it (just as) difficult to find the specific media query (search for "(max-width:480px)").