Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Last active August 29, 2015 14:17
Show Gist options
  • Save KittyGiraudel/6c346a5c216058605ea3 to your computer and use it in GitHub Desktop.
Save KittyGiraudel/6c346a5c216058605ea3 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
/// Mixin to increase selector specificity
/// @author Hugo Giraudel
/// @param {Number} $level [2] - Specificity level
/// @example scss - Increase selector specificity
/// .foo {
/// @include specific {
/// color: red;
/// }
/// }
@mixin specific($level: 2) {
$selector: &;
@for $i from 1 to $level {
$selector: selector-append($selector, &);
}
@at-root #{$selector} {
@content
}
}
.foo {
@include specific {
color: red;
}
@include specific(10) {
.bar {
background: tomato;
}
}
}
.foo.foo {
color: red;
}
.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo .bar {
background: tomato;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment