Skip to content

Instantly share code, notes, and snippets.

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

  • Save stowball/415d43ce191c38546e7f to your computer and use it in GitHub Desktop.

Select an option

Save stowball/415d43ce191c38546e7f to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
$mixin-denominator-numbers: (1 2 3) !default;
$_percentage-class-instances: () !default;
@mixin generate-percentage-classes() {
@each $denominator in $mixin-denominator-numbers {
$selector: ".u-#{$denominator * 100}pc";
@if (map-has-key($_percentage-class-instances, $selector)) {
$_percentage-class-instances: map-merge($_percentage-class-instances, ($selector: 2));
}
@else {
$_percentage-class-instances: map-merge($_percentage-class-instances, ($selector: 1));
}
@if (map-get($_percentage-class-instances, $selector) == 1) {
#{$selector} {
width: percentage($denominator);
}
}
}
}
@include generate-percentage-classes();
.u-100pc {
width: 100%;
}
.u-200pc {
width: 200%;
}
.u-300pc {
width: 300%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment