at-import / breakpoint

Really simple media queries in Sass
MIT License
2.09k stars 142 forks source link

Fallback output when nesting selectors #113

Closed jhummel closed 10 years ago

jhummel commented 10 years ago

Perhaps I'm just doing this wrong, but is there a solution for using the fallback when nesting selectors, and referencing the current selector after a new parent? (how's that for a mouthful) e.g.,

.my-class {
  width: 50%;

  .my-class-ancestor & {
    @include breakpoint($my-breakpoint, '.lt-ie9') {
      width: 100%;
    }
  }
}

The compiled CSS for this would look something like:

.my-class {
  width: 50%;
}

@media (...) {
  .my-class-ancestor .my-class {
    width: 100%;
  }
}

.my-class-ancestor .lt-ie9 .my-class {
  width: 100%;
}

I do this type of thing a lot when overriding selectors for a specific page - .lt-ie9 .home-page .my-class I would like for the fallback selector to put the fallback class before the entire selector instead of stuck in the middle. I'm not sure if this is possible, however. Is there any way around this, or is it just a pattern I should try to avoid?

Snugug commented 10 years ago

Breakpoint creates the output you're expecting.

http://sassmeister.com/gist/42a0b9fdf9f7f0e5c13a

In the future, for support questions, please file an issue on Stack Overflow. For bugs or feature requests, an issue here.