Skip to content

Instantly share code, notes, and snippets.

@jmahony
Created November 30, 2015 11:31
Show Gist options
  • Select an option

  • Save jmahony/7aafe04235bfae8c0f8a to your computer and use it in GitHub Desktop.

Select an option

Save jmahony/7aafe04235bfae8c0f8a to your computer and use it in GitHub Desktop.
Mixin that wraps content another selector
@mixin wrap($prefix) {
$selector: &;
@at-root #{$prefix} {
#{$selector} {
@content;
}
}
}
@mixin ie9() {
@include wrap($prefix: '.ie9') {
@content;
}
}
// This
.a {
.b {
transform: translate3d(0, 0, 0);
@include ie9 {
transform: translate(0, 0);
}
}
}
// would compile to
.a .b {
transform: translate3d(0, 0, 0);
}
.ie9 .a .b {
transform: translate(0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment