This project is deprecated and only remains for historical reasons.
A typographic SASS extension to help you easily maintain vertical-rhythm in your projects.
- Copy sass/_linegraphy.sass into your project's SASS directory
- Import the file into your project
@import linegraphy
Converts a static font-size to relative units
- $font-size: size of the elements font in px
Example:
p
@include font-size(16px)
Generates:
p {
font-size: 1em;
}
Calculates the elements line-height
- $font-size: size of the elements font in px
- $custom-line-height: (optional)
Example:
h1
@include line-height(48px, 48px)
p
@include line-height(16px)
Generates:
h1 {
line-height: 1em;
}
p {
font-size: 1.5em;
}
Creates rhythmed whitepace before an element
- $font-size: size of the elements font in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
p
@include line-before(16px, margin)
Generates:
p {
margin-top: 1.5em;
}
Creates rhythmed whitepace after an element
- $font-size: size of the elements font in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
p
@include line-after(16px, margin, 2)
Generates:
p {
margin-bottom: 3em;
}
Calculates the rhythmed whitepace for an element and divides it up before AND after an element
- $font-size: size of the elements font in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
p
@include line-both(16px, margin)
Generates:
p {
margin-top: 0.75em;
margin-bottom: 0.75em;
}
Creates rhythmed whitespace before an element and adds a "border-top" to it
- $font-size: size of the elements font in px
- $property: padding or margin
- $border-size: border size in px
- $border-style: solid, dashed, dotted, etc
- $border-color: hex, rgb, rgba, hsla
Example:
p
@include line-border-before(16px, padding, 1px, solid, #000)
Generates:
p {
border-top: 1px solid #000
padding-top: 1.5em;
}
Creates rhythmed whitespace after an element and adds a "border-bottom" to it
- $font-size: size of the elements font in px
- $property: padding or margin
- $border-size: border size in px
- $border-style: solid, dashed, dotted, etc
- $border-color: hex, rgb, rgba, hsla
Example:
p
@include line-border-after(16px, padding, 1px, solid, #000)
Generates:
p {
border-bottom: 1px solid #000
padding-bottom: 1.5em;
}
Creates rhythmed whitespace before a fixed height element
- $height: height of the element in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
img
@include line-fixed-before(16px, padding, 1)
display: block
height: 100px
width: 100px
Generates:
img {
padding-top: 1.25em;
display: block;
height: 100px;
width: 100px;
}
Creates rhythmed whitespace after a fixed height element
- $height: height of the element in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
img
@include line-fixed-after(16px, padding, 1)
display: block
height: 100px
width: 100px
Generates:
img {
padding-bottom: 1.25em;
display: block;
height: 100px;
width: 100px;
}
Calculates the rhythmed whitepace for a fixed height element and divides it up before AND after an element
- $height: height of the element in px
- $property: padding or margin
- $lines: integer (optional) multiplies the whitespace by nth
Example:
img
@include line-fixed-both(16px, padding, 1)
display: block
height: 100px
width: 100px
Generates:
img {
padding-top: 0.625em;
padding-bottom: 0.625em;
display: block;
height: 100px;
width: 100px;
}
Converts a static unit to a relative unit
- $target: px the static unit you want a relative unit from
- $context: px the targets parent unit
Example:
p
font-size: static-to-relative(16px)
Generates:
p {
font-size: 1em;
}
Converts a static unit to a relative unit
- context: em the relative unit you want a static unit from
Example:
p
font-size: relative-to-static(1em)
Generates:
p {
font-size: 16px;
}
Takes an elements height and returns the difference between it and the next multiple of the baseline
- context: em the relative unit you want a static unit from
Example:
img
height: 100px
margin-bottom: remainder(100px)
Generates:
img {
height: 100px;
/* 24px (line-height) * 5 = 120px - 100px (img height) = 20px */
margin-bottom: 20px;
}
Copyright (c) 2011 Jason Bellamy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.