Skip to content

Instantly share code, notes, and snippets.

@htmlzengarden
Created March 31, 2015 19:24
Show Gist options
  • Save htmlzengarden/7886e9a030db14417319 to your computer and use it in GitHub Desktop.
Save htmlzengarden/7886e9a030db14417319 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 incrase-specificity($selector, $specificity: 2) {
@if $specificity > 1 {
@include incrase-specificity($selector, $specificity - 1) {
&#{$selector} {
@content;
}
}
}
@else {
#{$selector} {
@content;
}
}
}
@include incrase-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