Skip to content

Instantly share code, notes, and snippets.

@bivald
Created March 7, 2014 09:02
Show Gist options
  • Save bivald/9408059 to your computer and use it in GitHub Desktop.
Save bivald/9408059 to your computer and use it in GitHub Desktop.
Sass mixin to convert photoshop line-height to CSS, photoshop letter-spacing to CSS
/* Reset rem to 10-based instead of default browser 16 */
html {
font-size: 62.5%;
}
/*
Photoshop does not apply line height to the first row, which CSS does. This creates all kinds of havock.
To calculate the correct offset for the first line we need the font-size and the lineheight, i.e:
@include line-height(22,30);
in Photoshop points/px (but with no unit)
*/
@mixin line-height($fontsize, $lineheight ){
line-height: ($lineheight) + px;
line-height: ($lineheight/10) + rem;
margin-top: (($lineheight - $fontsize)/2 * -1) + px;
margin-top: ((($lineheight - $fontsize)/2 * -1) / 10 ) + rem
}
/* Letter spacing is simpler.. stolen from somewhere */
@mixin letter-spacing($letterspacing) {
letter-spacing: $letterspacing/1000;
}
/* font-size to rem with backup, stolen from somewhere */
@mixin font-size($sizeValue: 16) {
font-size: ($sizeValue) + px;
font-size: ($sizeValue/10) + rem;
}
@strarsis
Copy link

Could this be put into a repository and published as eyeglass module on npm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment