question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Group media queries

See original GitHub issue

While the media query bubbling is great:

header {
    color: green;

    @media only screen (max-width: 500px) { color: red; }
}

footer {
    color: green;

    @media only screen (max-width: 500px) { color: red; }
}

Less generates fairly bloated code because it repeats the mediaquery selector each time its declared in the less file:

header {
  color: green;
}
@media only screen (max-width: 500px) {
  header {
    color: red;
  }
}
footer {
  color: green;
}
@media only screen (max-width: 500px) {
  footer {
    color: red;
  }
}

It would be nice if media queries could be grouped if they’re identical:

header {
  color: green;
}
footer {
  color: green;
}

@media only screen (max-width: 500px) {
  header {
    color: red;
  }
  footer {
    color: red;
  }
}

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Reactions:2
  • Comments:64 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
matthew-deancommented, Jan 20, 2015

Closing since this is supported by a plugin, and isn’t a priority to move into core (AFAIK - @less/admin correct if this is wrong).

1reaction
danielkatzcommented, Aug 4, 2013

IMO it makes sense to generalize the problem to scope grouping control which will provide solution for issue #930

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp-group-css-media-queries - npm
CSS postprocessing: group media queries. Useful for postprocessing preprocessed CSS files.. Latest version: 1.2.2, last published: 5 years ...
Read more >
Is there an advantage in grouping css media queries together?
Yeah profiles. Run CSS Selectors and you will get a profile of how long things take to run. Try this with group queries...
Read more >
Using media queries - CSS: Cascading Style Sheets | MDN
Media queries allow you to apply CSS styles depending on a device's general type (such as print vs. screen) or other characteristics such...
Read more >
A Complete Guide to CSS Media Queries
CSS Media queries are a way to target browser by certain characteristics, features, and user preferences, then apply styles based on those ...
Read more >
gulp-group-css-media-queries - npm package - Snyk
CSS postprocessing: group media queries. Useful for postprocessing preprocessed CSS files. This plugin is a wrapper for the group-css-media-queries plugin.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found