Skip to content

Instantly share code, notes, and snippets.

@Simounet
Created August 13, 2015 12:09
Show Gist options
  • Save Simounet/0d425476531dcf6cc304 to your computer and use it in GitHub Desktop.
Save Simounet/0d425476531dcf6cc304 to your computer and use it in GitHub Desktop.
Relative font size Compass mixin
@mixin relative-font-size( $px-size, $unit: 'rem', $context: $base-font-size ) {
@if $px-size == 0 {
@error "$px-size value can't be equalse to 0.";
}
@if unit( $px-size ) != "px" {
@error "$px-size must be value in pixels."
}
@if $unit != 'rem'
and $unit != 'em'
and $unit != '%' {
@error "$unit must be 'rem' or 'em' or '%'.";
}
font-size: $px-size;
font-size: $px-size / $context + 0#{$unit};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment