Last active
October 6, 2020 21:33
-
-
Save ademilter/7735040 to your computer and use it in GitHub Desktop.
fontsize-mixin
This file contains 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
// GLOBAL VARIABLE | |
$base-font-size-mobile: 16; | |
$base-font-size-desktop: 18; //min-width: 30em | |
$base-line-height: 1.5; | |
$desktop-width: pxToEm(480); | |
// PX to EM | |
// call: margin-bottom: pxToEm(10); // 10/18= .555555556em | |
// call: margin-bottom: pxToEm(10, m); 10/16= .625em | |
@function pxToEm($size, $device) { | |
@if $size == m { | |
@return $size / $base-font-size-mobile + em; | |
} | |
@else { | |
@return $size / $base-font-size-desktop + em; | |
} | |
} | |
// FONT SIZE | |
// call: @include font-size(32, 26); | |
@mixin font-size($mobile, $desktop) { | |
font-size: pxToEm($mobile); | |
@if $desktop != null and $desktop != "" { | |
@media all and (min-width: $desktop-width) { | |
font-size: pxToEm($desktop); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment