Skip to content

Instantly share code, notes, and snippets.

@icatalina
Created October 2, 2014 14:11
Show Gist options
  • Save icatalina/e7da1aa2c05efd9fa7c6 to your computer and use it in GitHub Desktop.
Save icatalina/e7da1aa2c05efd9fa7c6 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
$base-font-size: 10px;
$relative: 1em;
@function px2em( $pixels, $base : $base-font-size, $unit : $relative ) {
@if ( type_of( $pixels ) != 'number' ){ @return $pixels; }
@return if( $pixels == 0, 0, round(( $pixels / $base ) * $unit * 1000 ) / 1000 );
}
@function size( $pixels, $base : $base-font-size, $unit : $relative ) {
$new: ();
@each $pixel in $pixels {
$new: append($new, px2em($pixel, $base, $unit));
}
@return if( length($new) == 1, nth($new, 1), $new);
}
$a: 10px/3;
body { margin: size(3px auto 0 5px, 11px); padding: #333}
body { margin: size(2px 1px); }
body { margin: size(14px, 10px); }
body {
margin: 0.273em auto 0 0.455em;
padding: #333;
}
body {
margin: 0.2em 0.1em;
}
body {
margin: 1.4em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment