Created
March 27, 2013 20:38
-
-
Save erin-dot-io/5257813 to your computer and use it in GitHub Desktop.
Font-size pixel-parity REMs mixin for Sass/SCSS with legacy browser 'px' fallback. Neat!
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
// the mixin | |
@mixin font-size($size: 16) { | |
font-size: ($size) + px; | |
font-size: ($size / 16) + rem; | |
} | |
// example | |
h6 { @include font-size(11); } | |
// will compile to | |
h6 { | |
font-size: 11px; | |
font-size: 0.6875rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows you to set font size with the same numbering scheme as pixels ( 11 = 11px = 0.6875rem) while still giving you the ability to change font-size on the html tag inside media queries to scale text across your entire project.
Credit to https://github.com/aral/pixel-parity-rems
Thanks to this twitter thread: https://twitter.com/aral/status/311956401918468096 and @shaundunne (https://twitter.com/shaundunne) for creating this mixin, which I have shamelessly reproduced here.