Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Created October 20, 2013 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiebuilds/7076282 to your computer and use it in GitHub Desktop.
Save jamiebuilds/7076282 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.7)
// ----
$magic-number: 24px
$size: 31px
@function calculateEm($target, $context: $magic-number)
$emSize: 0
@if $target == 0
@return $emSize
@if $target > $context
@if $target < ($context * 2)
$emSize: ($context * 2) / $target
@else if $target < ($context * 3)
$emSize: ($context * 3) / $target
@else
$emSize: $context / $target
@return $emSize + 0em
test
value: calculateEm($size)
type-value: type-of(calculateEm($size))
type-test-1: type-of(1.54839em)
test-1: calculateEm($size) == 1.54839em
test-2: calculateEm($size) == calculateEm($size)
test {
value: 1.54839em;
type-value: number;
type-test-1: number;
test-1: false;
test-2: true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment