Skip to content

Instantly share code, notes, and snippets.

@paulakreuger
Forked from ijy/Compass px to em
Last active August 29, 2015 14:01
Show Gist options
  • Save paulakreuger/8c4ca82ab7d29ebd412f to your computer and use it in GitHub Desktop.
Save paulakreuger/8c4ca82ab7d29ebd412f to your computer and use it in GitHub Desktop.

Revisions

  1. paulakreuger revised this gist May 28, 2014. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions Compass px to em
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,9 @@
    @function em($target, $context: $base-font-size) {
    @if $target == 0 { @return 0 }
    @return $target / $context + 0em;
    }
    $browser-context: 16; // Default

    $base-font-size: 15px;
    @function em($pixels, $context: $browser-context) {
    @return #{$pixels/$context}em
    }

    h1 {
    font-size: em(21px, 15px); // Outputs 1.4em
    font-size: em(21, 15); // Outputs 1.4em
    }
  2. Ian Young revised this gist Dec 7, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Compass px to em
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    @function em($target, $context: $font-base) {
    @function em($target, $context: $base-font-size) {
    @if $target == 0 { @return 0 }
    @return $target / $context + 0em;
    }
  3. Ian Young created this gist Dec 7, 2011.
    10 changes: 10 additions & 0 deletions Compass px to em
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    @function em($target, $context: $font-base) {
    @if $target == 0 { @return 0 }
    @return $target / $context + 0em;
    }

    $base-font-size: 15px;

    h1 {
    font-size: em(21px, 15px); // Outputs 1.4em
    }