Last active
August 29, 2015 14:10
-
-
Save nixstrom/23e22814769ec5d8faa4 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.7) | |
// Compass (v1.0.1) | |
// ---- | |
$base-font-size: 16; | |
//Function to calculate rem value from expected pixel value | |
@function rem($values...) { | |
// How many values must we loop through? | |
$length: length($values); | |
// Variable to hold our final values | |
$output: ''; | |
@for $i from 1 through $length { | |
$value: nth($values, $i); | |
// If value is 0 or auto, preserve it as is | |
@if $value == 0 or $value == auto { | |
$output: #{$output + $value}; | |
} | |
@else { | |
// Convert input "base-pixel-value" to corresponding rem value | |
$value: $value/$base-font-size; | |
$output: #{$output + $value}rem; | |
} | |
// Unless it's the last value, add a whitespace | |
@if $i < $length { | |
$output: #{$output + " "}; | |
} | |
} | |
@return $output; | |
} | |
.foo { | |
font-size: rem(14); | |
padding: rem(16, auto, 0, 10); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.foo { | |
font-size: 0.875rem; | |
padding: 1rem auto 0 0.625rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment