Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save stowball/d841cbf7a6440dcd0a04 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
@mixin to-em-or-rem($unit, $properties, $sizes, $context, $sledgehammer) {
$values: ();
$sublists: false;
$unit: if($unit == "em", unquote("em"), unquote("rem"));
$important: if($sledgehammer, " !important", "");
@each $s in $sizes {
@if type-of($s) == list {
$sublists: true;
$vv: ();
@each $ss in $s {
$vv: append($vv, if(type-of($ss) == number and $ss != 0, #{$ss / $context}#{$unit}, $ss));
}
$values: append($values, join((), $vv));
}
@else {
$values: append($values, if(type-of($s) == number and $s != 0, #{$s / $context}#{$unit},
$s));
}
}
$value: join((), $values, if($sublists, comma, space));
@each $prop in $properties {
#{$prop}: $value#{$important};
}
}
@mixin to-em($properties, $sizes, $context: false, $sledgehammer: false) {
$context: if($context == false or $context == "", $font-size, $context);
@include to-em-or-rem("em", $properties, $sizes, $context, $sledgehammer);
}
@mixin to-rem($properties, $sizes, $sledgehammer: false) {
@include to-em-or-rem("rem", $properties, $sizes, $font-size, $sledgehammer);
}
$font-size: 16;
a {
@include to-em(margin, 16);
@include to-em(margin, 10, 12, true);
@include to-rem(padding, 12);
@include to-rem(padding, 12, true);
@include to-em(text-shadow, (#0d6e28 1 1) (#777 0 0 2), 20);
@include to-em(text-shadow, (#0d6e28 1 1) (#777 0 0 2), 20, true);
@include to-rem(text-shadow, (#0d6e28 1 1) (#777 0 0 2));
@include to-rem(text-shadow, (#0d6e28 1 1) (#777 0 0 2), true);
}
b {
@include to-em(margin padding, 12, 16, true);
@include to-em(margin padding, 16, false, true);
@include to-em(margin padding, 16, "", true);
}
a {
margin: 1em;
margin: 0.83333em !important;
padding: 0.75rem;
padding: 0.75rem !important;
text-shadow: #0d6e28 0.05em 0.05em, #777 0 0 0.1em;
text-shadow: #0d6e28 0.05em 0.05em, #777 0 0 0.1em !important;
text-shadow: #0d6e28 0.0625rem 0.0625rem, #777 0 0 0.125rem;
text-shadow: #0d6e28 0.0625rem 0.0625rem, #777 0 0 0.125rem !important;
}
b {
margin: 0.75em !important;
padding: 0.75em !important;
margin: 1em !important;
padding: 1em !important;
margin: 1em !important;
padding: 1em !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment