Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added @media bubbling/nesting/merging (similar to SASS) #634

Merged
merged 8 commits into from Feb 28, 2012

Conversation

mrcljx
Copy link
Contributor

@mrcljx mrcljx commented Feb 14, 2012

Also mentioned in #286 and #152. It would be nice if the following conversion could be made by Less:

#a {
  @media screen { ... }
}
@media screen {
  #a { ... }
}

This makes it easy to add media-specific styles without having to repeat selectors or break the flow of the stylesheet (quoted from SASS reference).

In 936ab7d I separated Media from Directive and added an algorithm which merges media-queries (also similar to SASS).

@media a, b and c {
  @media x, y { ... }
}
@media a and x, b and c and x, a and y, b and c and y { ... }

Note: A nested media-query will always be forced after the top-level media-query. In the following example the header AND the footer will be black iff a and b.

@media a {
   footer { color: white; }

  @media b {
    header { color: black }
    footer { color: black; }
  }

  header { color: white; }
}

@joeldrapper
Copy link

@sirlantis That looks really useful. I'm looking forward to using this.

@mrcljx
Copy link
Contributor Author

mrcljx commented Feb 17, 2012

Updated pull-request description to include infos on the last two commits (which add media-query condition merging).

@mrcljx
Copy link
Contributor Author

mrcljx commented Feb 17, 2012

Note: Using nested @media in mixins doesn't work correctly right now. Taking a look into that tomorrow.

@cloudhead
Copy link
Member

Very cool.

@alexpeattie
Copy link

+1, very useful

cloudhead pushed a commit that referenced this pull request Feb 28, 2012
@cloudhead cloudhead merged commit 2723c4e into less:master Feb 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants