Skip to content

Instantly share code, notes, and snippets.

@Nazcange
Created July 11, 2013 10:23
Show Gist options
  • Save Nazcange/5974319 to your computer and use it in GitHub Desktop.
Save Nazcange/5974319 to your computer and use it in GitHub Desktop.
Sass Mixin toolbox
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
/* convert font-size in px into rem with a px fallback */
$main-font-size : 10;
@mixin font-size($sizeValue: 10) {
font-size: $sizeValue + px;
font-size: calculateRem($sizeValue);
}
@function calculateRem($size) {
$remSize: $size / $main-font-size;
@return #{$remSize}rem;
}
/* create line-height from font-size and line height in same unit */
@mixin line-height($fontsize, $lineHeight){
line-height: $lineHeight/$fontsize;
}
/* add prefix for calc function and use fall back if needed */
@mixin calc($property, $expression, $default :"") {
@if $default !="" {
#{$property}: #{$default};
}
#{$property}: -moz-calc(#{$expression});
// #{$property}: -o-calc(#{$expression});
#{$property}: -webkit-calc(#{$expression});
#{$property}: calc(#{$expression});
}
/* convert font-size in px into rem with a px fallback */
/* create line-height from font-size and line height in same unit */
/* add prefix for calc function and use fall back if needed */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment