Skip to content

Instantly share code, notes, and snippets.

@techgraphics
Created May 30, 2015 19:45
Show Gist options
  • Save techgraphics/92bfb44447b3292475c4 to your computer and use it in GitHub Desktop.
Save techgraphics/92bfb44447b3292475c4 to your computer and use it in GitHub Desktop.
Typographic Functions
/*! MIT license */
/*! TYPOGRAPHIC FUNCTIONS */
@function pt-as-px($pt) {
$css-pixels-per-point: 4/3; /* Reference: http://www.thomasphinney.com/2011/03/point-size/ */
$px: $pt * $css-pixels-per-point;
@return #{$px}px;
}
@function h1-rem($rational) {
$h1: 1 + ( ( ($rational - 1) / 5 ) * 5 );
@return #{$h1}rem;
}
@function h2-rem($rational)
{
$h2: 1 + ( ( ($rational - 1) / 5 ) * 4 );
@return #{$h2}rem;
}
@function h3-rem($rational)
{
$h3: 1 + ( ( ($rational - 1) / 5 ) * 3 );
@return #{$h3}rem;
}
@function h4-rem($rational)
{
$h4: 1 + ( ( ($rational - 1) / 5 ) * 2 );
@return #{$h4}rem;
}
@function h5-rem($rational)
{
$h5: 1 + ( ( ($rational - 1) / 5 ) * 1 );
@return #{$h5}rem;
}
@function h6-rem($rational)
{
$h6: 1;
@return #{$h6}rem;
}
/*! end TYPOGRAPHIC FUNCTIONS */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment