Skip to content

Instantly share code, notes, and snippets.

@githiro
Created January 21, 2015 09:06
Show Gist options
  • Save githiro/7566d62eceee2c7fe381 to your computer and use it in GitHub Desktop.
Save githiro/7566d62eceee2c7fe381 to your computer and use it in GitHub Desktop.
SASS: font-size mixin.Get px and rem-based "font-size: value" set. Foundation framework's rem-calc() function is required.
@mixin font-size($sizeValue: 1.6, $force: false) {
$unit: unit($sizeValue);
@if $unit == "px" {
$sizeValue: strip-unit($sizeValue);
@if $force == true {
font-size: $sizeValue + px !important;
font-size: rem-calc($sizeValue) !important;
} @else {
font-size: $sizeValue + px;
font-size: rem-calc($sizeValue);
}
}
@else {
@if $force == true {
font-size: ($sizeValue * 16) + px !important;
font-size: $sizeValue + rem !important;
} @else {
font-size: ($sizeValue * 16) + px;
font-size: $sizeValue + rem;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment