Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
Forked from aquelito/output.css
Created August 2, 2012 21:25
Show Gist options
  • Save chrisjlee/3240798 to your computer and use it in GitHub Desktop.
Save chrisjlee/3240798 to your computer and use it in GitHub Desktop.
SCSS Compass Font Size - Vertical Rhythm
html {
font: 100%/1.5em "Helvetica Neue", Helvetica, Arial, sans-serif; }
h1, .h1 {
font-size: 4em;
line-height: 1.5em;
margin: 0.5em 0; }
h2, .h2 {
font-size: 3em;
line-height: 1.333em;
margin: 0.667em 0; }
h3, .h3 {
font-size: 2em;
line-height: 2em;
margin: 1em 0; }
h4, .h4 {
font-size: 1.75em;
line-height: 2.286em;
margin: 1.143em 0; }
h5, .h5 {
font-size: 1.5em;
line-height: 1.333em;
margin: 1.333em 0; }
h6, .h6 {
font-size: 1.333em;
line-height: 1.5em;
margin: 1.5em 0; }
.smaller {
font-size: 1em;
line-height: 2em; }
.small {
font-size: 1.167em;
line-height: 1.714em; }
.normal {
font-size: 1.333em;
line-height: 1.5em; }
@import "compass/typography/vertical_rhythm";
$base-font-size: 16px;
$base-line-height: 24px;
$browser-default-font-size: 16px;
$title-font-size: (h1 48px) (h2 36px) (h3 24px) (h4 21px) (h5 18px) (h6 16px);
$font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
$font-body: $font-sans;
@mixin establish-baseline($font-size: $base-font-size, $font-family: $font-body) {
$taille: 100% * $font-size / $browser-default-font-size;
$line-height: rhythm(1, $font-size);
html {
font: #{$taille}/#{$line-height} $font-family;
}
}
@mixin margin($taille:$base-font-size, $type:margin, $mt:1, $mb:1 ) {
@if ($mt == $mb) {
@if ($mt == 0) {
#{$type}: 0;
} @else {
#{$type}: rhythm($mt, $taille) 0;
}
} @else {
#{$type}: rhythm($mt, $taille) 0 rhythm($mb, $taille);
}
}
body {
@include baseline-grid-background($base-line-height, $color:#e1e1e1);
margin: 0;
}
@include establish-baseline; // html
@each $typo-array in $title-font-size {
$balise: nth($typo-array, 1);
$taille: nth($typo-array, 2);
#{$balise}, .#{$balise} {
@include adjust-font-size-to($taille);
@include margin($taille);
}
}
.smaller {
@include adjust-font-size-to(12px); }
.small {
@include adjust-font-size-to(14px); }
.normal {
@include adjust-font-size-to(16px); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment