Skip to content

Instantly share code, notes, and snippets.

@halofx
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save halofx/f00853e0607af378f111 to your computer and use it in GitHub Desktop.

Select an option

Save halofx/f00853e0607af378f111 to your computer and use it in GitHub Desktop.
PX to Rem with reset
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
// set rem and em to 10px
html { font-size: 62.5%; }
$base-font-size: 10px;
$rem-ratio: $base-font-size / 1rem;
@mixin rem($key,$px) {
#{$key}: $px;
#{$key}: $px/$rem-ratio;
}
// Usage
p {
@include rem(font-size,14px);
}
html {
font-size: 62.5%;
}
p {
font-size: 14px;
font-size: 1.4rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment