Skip to content

Instantly share code, notes, and snippets.

@tyssen
Created September 2, 2011 06:20
Show Gist options
  • Save tyssen/1188018 to your computer and use it in GitHub Desktop.
Save tyssen/1188018 to your computer and use it in GitHub Desktop.
LESS baseline grid calculator mixins
@defaultfontsize: 16;
@defaultlineheight: @defaultfontsize*1.5;
.font(@fontsize:16,@lineheight:24,@multiplier:1,@lineheightreducer:1) {
font-size: (@fontsize/@defaultfontsize)*1em;
line-height: @lineheight/@fontsize/@lineheightreducer;
margin: (@lineheight/@fontsize*(@multiplier/(@lineheight/@defaultlineheight)))*1em 0 0;
}
.boxes(@paddingtop:1,@paddingbottom:1,@bordertop:0,@borderbottom:0) {
@border-top-width: @bordertop*1px;
@border-bottom-width: @borderbottom*1px;
padding-top: e(%("%sem%s", (((@paddingtop*@defaultlineheight)-@bordertop)/@defaultfontsize), `@{bordertop}>=1?'; border-top-width: @{border-top-width}':''` ));
padding-bottom: e(%("%sem%s", (((@paddingbottom*@defaultlineheight)-@borderbottom)/@defaultfontsize)*1, `@{borderbottom}>=1?'; border-bottom-width: @{border-bottom-width}':''` ));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment