Skip to content

Instantly share code, notes, and snippets.

@Victa
Created December 31, 2011 14:36
Show Gist options
  • Select an option

  • Save Victa/1544160 to your computer and use it in GitHub Desktop.

Select an option

Save Victa/1544160 to your computer and use it in GitHub Desktop.
Converting px to ems with LESS
/* 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 );
}
@Victa

Victa commented Dec 31, 2011

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment