1.2.0 • Published 9 years ago
voidcss-vertical-rhythm v1.2.0
Vertical Rhythm plugin
This is an utility plugin: it doesn't output anything when imported. It just provides variables, mixins, functions.
Introduction
Vertical Rhythm is a concept to keep elements aligned to a uniform, vertical grid. It's an application of repetition in design and it make content more readable.
More info:
Quick start
Install
npm install voidcss-vertical-rhythm
Import it:
@import '~voidcss-vertical-rhythm';
Define base font size and line-height:
$vr-font-size: 14px; // Defaults to 1rem, which is 16px by default. $vr-line-height: 1.2; // Defaults to 1.5. Depends on typeface.
Include
vr-init
in the root element (usuallyhtml
):html { // Set default font-size and line-height. @include vr-init; }
Use
vr
function to calculate distances:// It's possible to use asymmetrical margins // as long as sum of vertical space inside element // is multiply of line-height. .lead { margin-top: vr(0.7); margin-bottom: vr(0.3); }
Use
vr-scale
to calculate line-height for different font sizes (eg. headings):h1 { $size: 36px; $baseline: vr-scale($size); font-size: $size; line-height: $baseline; margin-top: vr(0.7, $baseline); margin-bottom: vr(0.3, $baseline); }
Use
vr-grid
to display baseline grid for debugging:body { @include vr-grid; }