Skip to content

Instantly share code, notes, and snippets.

@jbrz0
Created April 25, 2016 06:46
Show Gist options
  • Save jbrz0/d349e2f46c2a101d83f08cf57b692b51 to your computer and use it in GitHub Desktop.
Save jbrz0/d349e2f46c2a101d83f08cf57b692b51 to your computer and use it in GitHub Desktop.
Sass mixin for setting default rem font sizes
// 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