Created
April 25, 2016 06:46
-
-
Save jbrz0/d349e2f46c2a101d83f08cf57b692b51 to your computer and use it in GitHub Desktop.
Sass mixin for setting default rem font sizes
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
// Define default font size | |
@function calculateRem($size) { | |
$remSize: $size / 16px; | |
@return $remSize * 1rem; | |
} | |
@mixin font-size($size) { | |
font-size: $size; | |
font-size: calculateRem($size); | |
} | |
//Usage | |
p { | |
@include font-size(14px) | |
} | |
//Output | |
p { | |
font-size: 14px; //For unsupported browsers | |
font-size: 0.8rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment