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/6a9795164a95f487dd1d to your computer and use it in GitHub Desktop.
Save borntorun/6a9795164a95f487dd1d to your computer and use it in GitHub Desktop.
less mixin to convert px to em/percent step-6
.convert-px(@unit; @tag; @px; @context: 16; @important:~'') {
.calc(@px; @multiply; @context) {
@ret-convert-px:(@px/@context)*@multiply;
}
.apply(@tag; @px; @context; @multiply; @sufix) {
.calc(@px, @multiply, @context);
@{tag}: @ret-convert-px + @sufix @important;
}
.unit(to-em; @tag; @px; @context) {
.apply(@tag, @px, @context, 1, 0em);
}
.unit(to-percent; @tag; @px; @context) {
.apply(@tag, @px, @context, 100, 0%);
}
.unit(@unit, @tag, @px, @context);
}
@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