Skip to content

Instantly share code, notes, and snippets.

@htmlzengarden
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htmlzengarden/4d029a2ae2f724c95505 to your computer and use it in GitHub Desktop.
Save htmlzengarden/4d029a2ae2f724c95505 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<h1><span class="foo">foo<span class="bar">bar</span></span></h1>
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
@mixin increase-specificity($selector, $specificity: 2) {
@if $specificity > 1 {
@include increase-specificity($selector, $specificity - 1) {
&#{$selector} {
@content;
}
}
}
@else {
#{$selector} {
@content;
}
}
}
@include increase-specificity('.foo') {
color: black;
.bar {
color: black;
}
}
.foo {
color: green;
.bar {
color: red;
}
}
.foo.foo {
color: black;
}
.foo.foo .bar {
color: black;
}
.foo {
color: green;
}
.foo .bar {
color: red;
}
<h1><span class="foo">foo<span class="bar">bar</span></span></h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment