Created
December 31, 2011 14:36
-
-
Save Victa/1544160 to your computer and use it in GitHub Desktop.
Converting px to ems with LESS
This file contains hidden or 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
| /* Create variables [optional] */ | |
| @basefont: 14; // in pixels | |
| @baseline: 20; // in pixels | |
| /* Create a converter namespace [optional] */ | |
| #pxtoem { | |
| /* Create convert mixin [required] */ | |
| .font-size( @target: @basefont, @context: @basefont ) { | |
| font-size: (@target / @context) + 0em; | |
| } | |
| } | |
| /* Example */ | |
| a { | |
| #pxtoem > .font-size( 10, 14 ); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://www.ifdattic.com/2011/10/19/converting-px-to-ems-with-less/