Skip to content

Instantly share code, notes, and snippets.

@dantman
Last active April 17, 2018 22:07
Show Gist options
  • Save dantman/841b85ab34ea6af93ac2 to your computer and use it in GitHub Desktop.
Save dantman/841b85ab34ea6af93ac2 to your computer and use it in GitHub Desktop.
Material Design sp units (px unit that scale to the user's font settings) using rems
html {
font-size: 14px;
}
/**
* PostCSS
* Use a custom PostCSS to convert #sp to rems by dividing the number by 14 and expressing it as #rem
*/
body {
/* Device */ font-size: 14sp; /* -> 1rem */
/* Desktop */ font-size: 13sp; /* -> 0.92857rem */
}
/** SASS */
@function sp($sp) {
@return ($sp / 14) * 1rem;
}
body {
/* Device */ font-size: sp(14);
/* Desktop */ font-size: sp(13);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment