Skip to content

Instantly share code, notes, and snippets.

@autovalue
Created December 17, 2015 15:18
Show Gist options
  • Save autovalue/15c9db923d9aa64696cb to your computer and use it in GitHub Desktop.
Save autovalue/15c9db923d9aa64696cb to your computer and use it in GitHub Desktop.
SASS mixin for appending a selector to the parent of the current rule set.
/// Nested [mixin]
/// --------------
/// Prepend a css rule to the current rule set.
/// @content : <content>
/// @param $selector : <span>
/// @param $isParent : <span> Whether the $selector will be applied as a parent or not.
@mixin prepend-selector($selector, $isParent: true) {
@if($isParent) {
@at-root #{$selector} & {
@content;
}
} @else {
@at-root #{$selector}#{&} {
@content;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment