Relative Font Size Mixin For LessCSS

This snippet sets the font-size on the body to a percentage of 16px, and also creates a mixin for setting relative font sizes and bottom margin in ems.  This eliminates the need to calculate percentages manually.

@base-px: 15;
@base-size: percentage(@base-px / 16);

.font-size (@px, @margin : 0) {
  font-size: percentage(@px / @base-px);
  margin: 0 0 (0em + (@margin / @px)) 0;
}

body {
  font-size: @base-size;
}

Tags

lesscss css