Created
July 11, 2013 10:23
-
-
Save Nazcange/5974319 to your computer and use it in GitHub Desktop.
Sass Mixin toolbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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