Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Created August 29, 2014 05:46
Show Gist options
  • Save jakob-e/9fcb2375b3c57e961e8a to your computer and use it in GitHub Desktop.
Save jakob-e/9fcb2375b3c57e961e8a to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div id="scssdebug">scssdebug</div>
// ----
// Sass (v3.4.1)
// Compass (v1.0.1)
// ----
@function isNaN($val) { @return type-of($val)!=number; }
@function conv($val, $to-unit){
$from-unit:unit($val);
$conv-unit:1px - 1px;
@return $conv-unit + $val;
}
@function convert-to-unit($string){
$units:(px:1px, px:1pt, pc:1pc, in:1in, mm:1mm, cm:1cm, // Absolute
em:1em, rem:1rem, ch:1ch, ex:1ex, // Relative - font based
vv:1vw, vh:1vh, vmin:1vmin, vmax:1vmax, // Relative - viewport based
deg:1deg, turn:1turn, grad:1grad, // Angles
s:1s, ms:1ms, // Time
hz:1hz, kHz:1khz, // Frequencies
dpi:1dpi, dpcm:1dpcm, dppx:1dppx // Resolutions
);
$index: index($strings, $unit);
}
.foo { hey:conv(120pt,px) }
.foo {
hey: 160px;
}
<div id="scssdebug">scssdebug</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment