Skip to content

Instantly share code, notes, and snippets.

@jdsteinbach
Created March 21, 2014 18:21
Show Gist options
  • Select an option

  • Save jdsteinbach/9692463 to your computer and use it in GitHub Desktop.

Select an option

Save jdsteinbach/9692463 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.3)
// Compass (v1.0.0.alpha.18)
// ----
$fsizes: (
p-smallest: 16,
p-small: 18,
p: 22,
subheading: 24,
heading-small: 32,
heading: 42,
hero-q: 156,
hero-a: 84
);
@function strip-unit($num) {
@if $num == auto or $num == inherit {
@return $num;
}
@else {
@return $num / ($num * 0 + 1);
}
}
@mixin px-rem($property, $value) {
$pxValues: "";
$remValues: "";
$value: strip-unit($value);
@if $value == auto or $value == inherit or $value == 0 {
$pxValues: #{$pxValues + $value};
}
@else {
$pxValues: #{$pxValues + $value}px;
}
@if $value == auto or $value == inherit or $value == 0 {
$remValues: "";
}
@else {
$remValues: #{$remValues + $value / 10}rem;
}
#{$property}: $pxValues;
@if $remValues != "" {
#{$property}: $remValues;
}
}
@each $label, $size in $fsizes {
%fs-#{$label} {
@include px-rem(font-size, $size);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment