Skip to content

Instantly share code, notes, and snippets.

@erikjung
Created April 10, 2013 07:47
Show Gist options
  • Select an option

  • Save erikjung/5352629 to your computer and use it in GitHub Desktop.

Select an option

Save erikjung/5352629 to your computer and use it in GitHub Desktop.
Type scaffolding with LESS 1.4 and Golden Ratio type measurements
@font-size-alpha: 45;
@font-size-beta: 28;
@font-size-gamma: 22;
@font-size-delta: 17;
@font-size-epsilon: 13;
@baseline: 28;
@type-unit: rem;
.font-size (@size) when (@type-unit = rem) {
@font-size: (@size / 16);
font-size: unit(@font-size, @type-unit);
}
.font-size (@size) when (@type-unit = px) {
font-size: unit(@size, @type-unit);
}
.margin-bottom (@size) when (@type-unit = rem) {
@font-size: (@size / 16);
margin-bottom: unit(@font-size, @type-unit);
}
.margin-bottom (@size) when (@type-unit = px) {
margin-bottom: unit(@size, @type-unit);
}
.line-height (@font-size) {
@line-height: (ceil(@font-size / @baseline) * @baseline);
line-height: (@line-height / @font-size);
}
.block {
.margin-bottom(@baseline);
}
p:extend(.block) {
}
h1:extend(.block) {
.font-size(@font-size-alpha);
.line-height(@font-size-alpha);
}
h2:extend(.block) {
.font-size(@font-size-beta);
.line-height(@font-size-beta);
}
h3:extend(.block) {
.font-size(@font-size-gamma);
.line-height(@font-size-gamma);
}
h4:extend(.block) {
.font-size(@font-size-delta);
.line-height(@font-size-delta);
}
h5,
h6 {
.font-size(@font-size-epsilon);
.line-height(@font-size-epsilon);
}
body {
.font-size(@font-size-delta);
.line-height(@font-size-delta);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment