Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save KittyGiraudel/707fe9fada1ea8814e94 to your computer and use it in GitHub Desktop.

Select an option

Save KittyGiraudel/707fe9fada1ea8814e94 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
/// Hacking specificity made easy
/// If you have to use this, you are either using a shitty framework
/// or doing something wrong. In any case, good luck.
///
/// @param {String} $class - Class to multiply
/// @param {Number} $level (1) - Number of times to multiply `$class`
@mixin specificity-hack($class, $level: 1) {
$selector: $class;
@for $i from 1 through $level {
$selector: selector-append($selector, $class);
}
#{$selector} { @content; }
}
specificity[is="hard"].you-know {
content: "Well, kinda...";
}
@include specificity-hack('.hack') {
color: "Look ma, 2 classes!";
}
@include specificity-hack('.hack', 41) {
content: "Grab your towel and don't panic";
}
@include specificity-hack('.Na', 16) {
BATMAN {
content: "I'm Batman.";
}
}
specificity[is="hard"].you-know {
content: "Well, kinda...";
}
.hack.hack {
color: "Look ma, 2 classes!";
}
.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack.hack {
content: "Grab your towel and don't panic";
}
.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na.Na BATMAN {
content: "I'm Batman.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment