Skip to content

Instantly share code, notes, and snippets.

@jasonkmccoy
Created March 12, 2015 23:55
Show Gist options
  • Save jasonkmccoy/1ddf7ac9a7dc0014b35f to your computer and use it in GitHub Desktop.
Save jasonkmccoy/1ddf7ac9a7dc0014b35f to your computer and use it in GitHub Desktop.
Set a rem font size with pixel fallback (using a function and a mixin) http://zerosixthree.se/8-sass-mixins-you-must-have-in-your-toolbox/
p {
font-size: 14px; //Will be overridden if browser supports rem
font-size: 0.8rem;
}
p {
@include font-size(14px)
}
@function calculateRem($size) {
$remSize: $size / 16px;
@return $remSize * 1rem;
}
@mixin font-size($size) {
font-size: $size;
font-size: calculateRem($size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment