Skip to content

Instantly share code, notes, and snippets.

@Vlasterx
Last active November 23, 2015 08:48
Show Gist options
  • Save Vlasterx/d1e787bca72c8756e9d2 to your computer and use it in GitHub Desktop.
Save Vlasterx/d1e787bca72c8756e9d2 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$sizePx: 18px;
$basePx: 16px;
$unit--rem: true;
// CHECK BOOLEAN VALUE
@function bool($value: false) {
@if $value == false or
$value == "" or
$value == "false" or
$value == 'false' or
$value == 0 {
@return false;
}
@return true;
}
// Converts PX to REM based on base font size
@function rem($sizePx, $baseFontSizePx) {
@return ($sizePx / $baseFontSizePx) * 1rem;
}
// Font size mixin
@mixin font-size($sizePx, $basePx, $important: false) {
@if bool($important) == false {
font-size: round($sizePx);
@if bool($unit--rem) == true { font-size: rem($sizePx, $basePx); }
}
@else {
font-size: round($sizePx) !important;
@if bool($unit--rem) == true { font-size: rem($sizePx, $basePx) !important; }
}
}
// Test
.test {
@include font-size($sizePx, $basePx, true);
}
.test {
font-size: 18px !important;
font-size: 1.125rem !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment