Skip to content

Instantly share code, notes, and snippets.

@borntorun
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borntorun/f10a94cccd12bb96c19a to your computer and use it in GitHub Desktop.
Save borntorun/f10a94cccd12bb96c19a to your computer and use it in GitHub Desktop.
less mixin to convert px to em/percent step-5
#convert-px {
.calc(@px; @context; @multiply) {
@ret-convert-px:(@px/@context)*@multiply;
}
.em(@tag; @px; @context) {
.calc(@px, @context, 1);
.apply(@tag) {
@{tag}: @ret-convert-px + 0em;
}
.apply(@tag);
}
.percent(@tag; @px; @context) {
.calc(@px, @context, 100);
.apply(@tag) {
@{tag}: @ret-convert-px + 0%;
}
.apply(@tag);
}
}
@borntorun
Copy link
Author

gist from blog post

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