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/a566ab29174f022d5bb7 to your computer and use it in GitHub Desktop.
Save borntorun/a566ab29174f022d5bb7 to your computer and use it in GitHub Desktop.
less mixin to convert px to em/percent step-4
#convert-px {
.calc(@px; @context; @multiply) {
@ret-convert-px:(@px/@context)*@multiply;
}
.em(@tag; @px; @context) {
.calc(@px, @context, 1);
.apply(font) { font-size: @ret-convert-px + 0em; }
.apply(padding) { padding: @ret-convert-px + 0em; }
.apply(@tag);
}
.percent(@tag; @px; @context) {
.calc(@px, @context, 100);
.apply(font) { font-size: @ret-convert-px + 0%; }
.apply(padding) { padding: @ret-convert-px + 0%; }
.apply(@tag);
}
}
.myclass1 {
#convert-px > .em(font,16,16);
}
.myclass2 {
#convert-px > .percent(padding,8,16);
}
@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